Add additional safety checks missed in first pass
This commit is contained in:
@@ -739,9 +739,9 @@ void Chunk::rebuild_SPU()
|
|||||||
{
|
{
|
||||||
// 4J - get tile from those copied into our local array in earlier optimisation
|
// 4J - get tile from those copied into our local array in earlier optimisation
|
||||||
unsigned char tileId = pOutData->getTile(x,y,z);
|
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);
|
shared_ptr<TileEntity> et = region.getTileEntity(x, y, z);
|
||||||
if (TileEntityRenderDispatcher::instance->hasRenderer(et))
|
if (TileEntityRenderDispatcher::instance->hasRenderer(et))
|
||||||
@@ -754,6 +754,7 @@ void Chunk::rebuild_SPU()
|
|||||||
{
|
{
|
||||||
|
|
||||||
Tile *tile = Tile::tiles[tileId];
|
Tile *tile = Tile::tiles[tileId];
|
||||||
|
if (!tile) continue;
|
||||||
int renderLayer = tile->getRenderLayer();
|
int renderLayer = tile->getRenderLayer();
|
||||||
|
|
||||||
if (renderLayer != currentLayer)
|
if (renderLayer != currentLayer)
|
||||||
|
|||||||
@@ -1588,6 +1588,10 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
|||||||
if(iRecipe == -1)
|
if(iRecipe == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int recipeCount = (int)Recipes::getInstance()->getRecipies()->size();
|
||||||
|
if(iRecipe < 0 || iRecipe >= recipeCount)
|
||||||
|
return;
|
||||||
|
|
||||||
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
|
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
|
||||||
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
|
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -1077,7 +1077,12 @@ void ServerLevel::entityRemoved(shared_ptr<Entity> e)
|
|||||||
|
|
||||||
shared_ptr<Entity> ServerLevel::getEntity(int id)
|
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)
|
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e)
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ bool WinsockNetLayer::JoinGame(const char* ip, int port)
|
|||||||
|
|
||||||
bool WinsockNetLayer::SendOnSocket(SOCKET sock, const void* data, int dataSize)
|
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
|
// 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
|
// send() blocks (TCP window full, slow WiFi), every other write thread stalls
|
||||||
|
|||||||
@@ -157,6 +157,9 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
|
|||||||
shared_ptr<ItemInstance> clickedEntity = nullptr;
|
shared_ptr<ItemInstance> clickedEntity = nullptr;
|
||||||
shared_ptr<Inventory> inventory = player->inventory;
|
shared_ptr<Inventory> inventory = player->inventory;
|
||||||
|
|
||||||
|
if (slotIndex < 0 || slotIndex >= (int)slots.size())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
if (clickType == CLICK_QUICK_CRAFT)
|
if (clickType == CLICK_QUICK_CRAFT)
|
||||||
{
|
{
|
||||||
int expectedStatus = quickcraftStatus;
|
int expectedStatus = quickcraftStatus;
|
||||||
@@ -558,12 +561,13 @@ bool AbstractContainerMenu::isPauseScreen()
|
|||||||
|
|
||||||
void AbstractContainerMenu::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
|
void AbstractContainerMenu::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
|
||||||
{
|
{
|
||||||
|
if (slot >= slots.size()) return;
|
||||||
getSlot(slot)->set(item);
|
getSlot(slot)->set(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractContainerMenu::setAll(ItemInstanceArray *items)
|
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] );
|
getSlot(i)->set( (*items)[i] );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user