diff --git a/Minecraft.Client/ServerPlayer.cpp b/Minecraft.Client/ServerPlayer.cpp index 87da9c61c..f57e8a3c9 100644 --- a/Minecraft.Client/ServerPlayer.cpp +++ b/Minecraft.Client/ServerPlayer.cpp @@ -146,7 +146,8 @@ void ServerPlayer::flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFou if( ( *removedFound ) == false ) { *removedFound = true; - memset(flags, 0, 2048/32); + // before this left 192 bytes uninitialized!!!!! + memset(flags, 0, (2048 / 32) * sizeof(unsigned int)); } for(int index : entitiesToRemove) diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index d754330b5..924312e59 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -96,9 +96,20 @@ int Entity::getSmallId() puiUsedFlags++; } +#ifdef MINECRAFT_SERVER_BUILD + // in mc server dedi, a server with 8+ playerrs can cause this to go wack + int fallbackId = Entity::entityCounter++; + + if (entityCounter == 0x7ffffff) + { + entityCounter = 2048; + } + return fallbackId; +#else app.DebugPrintf("Out of small entity Ids... possible leak?\n"); __debugbreak(); return -1; +#endif } void Entity::countFlagsForPIX() diff --git a/Minecraft.World/Level.h b/Minecraft.World/Level.h index eb750affc..2be874722 100644 --- a/Minecraft.World/Level.h +++ b/Minecraft.World/Level.h @@ -16,7 +16,12 @@ using namespace std; // 4J Stu - This value should be big enough that we don't get any crashes causes by memory overwrites, // however it does seem way too large for what is actually needed. Needs further investigation +#ifdef MINECRAFT_SERVER_BUILD +// fixes a crash when 8+ players are present +#define LEVEL_CHUNKS_TO_UPDATE_MAX (32*32*8) +#else #define LEVEL_CHUNKS_TO_UPDATE_MAX (19*19*8) +#endif class Vec3; class ChunkSource;