Add additional safety checks missed in first pass

This commit is contained in:
Loki Rautio
2026-03-09 05:18:40 -05:00
parent b1277c0e1b
commit 1d610300a8
5 changed files with 19 additions and 5 deletions

View File

@@ -739,9 +739,9 @@ void Chunk::rebuild_SPU()
{
// 4J - get tile from those copied into our local array in earlier optimisation
unsigned char tileId = pOutData->getTile(x,y,z);
if (tileId > 0)
if (tileId > 0 && tileId != 0xff)
{
if (currentLayer == 0 && Tile::tiles[tileId]->isEntityTile())
if (currentLayer == 0 && Tile::tiles[tileId] && Tile::tiles[tileId]->isEntityTile())
{
shared_ptr<TileEntity> et = region.getTileEntity(x, y, z);
if (TileEntityRenderDispatcher::instance->hasRenderer(et))
@@ -754,6 +754,7 @@ void Chunk::rebuild_SPU()
{
Tile *tile = Tile::tiles[tileId];
if (!tile) continue;
int renderLayer = tile->getRenderLayer();
if (renderLayer != currentLayer)

View File

@@ -1588,6 +1588,10 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
if(iRecipe == -1)
return;
int recipeCount = (int)Recipes::getInstance()->getRecipies()->size();
if(iRecipe < 0 || iRecipe >= recipeCount)
return;
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);

View File

@@ -1077,7 +1077,12 @@ void ServerLevel::entityRemoved(shared_ptr<Entity> e)
shared_ptr<Entity> ServerLevel::getEntity(int id)
{
return entitiesById[id];
auto it = entitiesById.find(id);
if (it != entitiesById.end())
{
return it->second;
}
return nullptr;
}
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e)

View File

@@ -404,7 +404,7 @@ bool WinsockNetLayer::JoinGame(const char* ip, int port)
bool WinsockNetLayer::SendOnSocket(SOCKET sock, const void* data, int dataSize)
{
if (sock == INVALID_SOCKET || dataSize <= 0) return false;
if (sock == INVALID_SOCKET || dataSize <= 0 || dataSize > WIN64_NET_MAX_PACKET_SIZE) return false;
// TODO: s_sendLock is a single global lock for ALL sockets. If one client's
// send() blocks (TCP window full, slow WiFi), every other write thread stalls

View File

@@ -157,6 +157,9 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
shared_ptr<ItemInstance> clickedEntity = nullptr;
shared_ptr<Inventory> inventory = player->inventory;
if (slotIndex < 0 || slotIndex >= (int)slots.size())
return nullptr;
if (clickType == CLICK_QUICK_CRAFT)
{
int expectedStatus = quickcraftStatus;
@@ -558,12 +561,13 @@ bool AbstractContainerMenu::isPauseScreen()
void AbstractContainerMenu::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{
if (slot >= slots.size()) return;
getSlot(slot)->set(item);
}
void AbstractContainerMenu::setAll(ItemInstanceArray *items)
{
for (unsigned int i = 0; i < items->length; i++)
for (unsigned int i = 0; i < items->length && i < slots.size(); i++)
{
getSlot(i)->set( (*items)[i] );
}