Removed index bounds checking in some chunk functions, if you error blame Grum.

This commit is contained in:
LexManos 2013-04-03 02:07:51 -07:00
parent 6df717db5a
commit 42875b70d9
1 changed files with 16 additions and 86 deletions

View File

@ -134,37 +134,7 @@
} }
/** /**
@@ -542,7 +635,7 @@ @@ -621,9 +714,13 @@
*/
public int getBlockID(int par1, int par2, int par3)
{
- if (par2 >> 4 >= this.storageArrays.length)
+ if (par2 >> 4 >= this.storageArrays.length || par2 >> 4 < 0)
{
return 0;
}
@@ -558,7 +651,7 @@
*/
public int getBlockMetadata(int par1, int par2, int par3)
{
- if (par2 >> 4 >= this.storageArrays.length)
+ if (par2 >> 4 >= this.storageArrays.length || par2 >> 4 < 0)
{
return 0;
}
@@ -591,6 +684,11 @@
}
else
{
+ if (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0)
+ {
+ return false;
+ }
+
ExtendedBlockStorage extendedblockstorage = this.storageArrays[par2 >> 4];
boolean flag = false;
@@ -621,9 +719,13 @@
{ {
Block.blocksList[l1].breakBlock(this.worldObj, j2, par2, k2, l1, i2); Block.blocksList[l1].breakBlock(this.worldObj, j2, par2, k2, l1, i2);
} }
@ -181,7 +151,7 @@
} }
} }
@@ -641,7 +743,7 @@ @@ -641,7 +738,7 @@
} }
else else
{ {
@ -190,7 +160,7 @@
{ {
if (par2 >= k1) if (par2 >= k1)
{ {
@@ -665,29 +767,21 @@ @@ -665,29 +762,21 @@
Block.blocksList[par4].onBlockAdded(this.worldObj, j2, par2, k2); Block.blocksList[par4].onBlockAdded(this.worldObj, j2, par2, k2);
} }
@ -223,16 +193,7 @@
} }
} }
@@ -702,7 +796,7 @@ @@ -722,7 +811,7 @@
*/
public boolean setBlockMetadata(int par1, int par2, int par3, int par4)
{
- ExtendedBlockStorage extendedblockstorage = this.storageArrays[par2 >> 4];
+ ExtendedBlockStorage extendedblockstorage = (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0 ? null : storageArrays[par2 >> 4]);
if (extendedblockstorage == null)
{
@@ -722,7 +816,7 @@
extendedblockstorage.setExtBlockMetadata(par1, par2 & 15, par3, par4); extendedblockstorage.setExtBlockMetadata(par1, par2 & 15, par3, par4);
int j1 = extendedblockstorage.getExtBlockID(par1, par2 & 15, par3); int j1 = extendedblockstorage.getExtBlockID(par1, par2 & 15, par3);
@ -241,46 +202,15 @@
{ {
TileEntity tileentity = this.getChunkBlockTileEntity(par1, par2, par3); TileEntity tileentity = this.getChunkBlockTileEntity(par1, par2, par3);
@@ -743,7 +837,7 @@ @@ -835,6 +924,7 @@
*/
public int getSavedLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4)
{
- ExtendedBlockStorage extendedblockstorage = this.storageArrays[par3 >> 4];
+ ExtendedBlockStorage extendedblockstorage = (par3 >> 4 >= storageArrays.length || par3 >> 4 < 0 ? null : storageArrays[par3 >> 4]);
return extendedblockstorage == null ? (this.canBlockSeeTheSky(par2, par3, par4) ? par1EnumSkyBlock.defaultLightValue : 0) : (par1EnumSkyBlock == EnumSkyBlock.Sky ? (this.worldObj.provider.hasNoSky ? 0 : extendedblockstorage.getExtSkylightValue(par2, par3 & 15, par4)) : (par1EnumSkyBlock == EnumSkyBlock.Block ? extendedblockstorage.getExtBlocklightValue(par2, par3 & 15, par4) : par1EnumSkyBlock.defaultLightValue));
}
@@ -753,6 +847,11 @@
*/
public void setLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4, int par5)
{
+ if (par3 >> 4 >= storageArrays.length || par3 >> 4 < 0)
+ {
+ return;
+ }
+
ExtendedBlockStorage extendedblockstorage = this.storageArrays[par3 >> 4];
if (extendedblockstorage == null)
@@ -781,7 +880,7 @@
*/
public int getBlockLightValue(int par1, int par2, int par3, int par4)
{
- ExtendedBlockStorage extendedblockstorage = this.storageArrays[par2 >> 4];
+ ExtendedBlockStorage extendedblockstorage = (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0 ? null : storageArrays[par2 >> 4]);
if (extendedblockstorage == null)
{
@@ -834,7 +933,7 @@
{
k = this.entityLists.length - 1; k = this.entityLists.length - 1;
} }
-
+ MinecraftForge.EVENT_BUS.post(new EntityEvent.EnteringChunk(par1Entity, this.xPosition, this.zPosition, par1Entity.chunkCoordX, par1Entity.chunkCoordZ)); + MinecraftForge.EVENT_BUS.post(new EntityEvent.EnteringChunk(par1Entity, this.xPosition, this.zPosition, par1Entity.chunkCoordX, par1Entity.chunkCoordZ));
par1Entity.addedToChunk = true; par1Entity.addedToChunk = true;
par1Entity.chunkCoordX = this.xPosition; par1Entity.chunkCoordX = this.xPosition;
par1Entity.chunkCoordY = k; par1Entity.chunkCoordY = k;
@@ -884,33 +983,32 @@ @@ -884,33 +974,32 @@
ChunkPosition chunkposition = new ChunkPosition(par1, par2, par3); ChunkPosition chunkposition = new ChunkPosition(par1, par2, par3);
TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.get(chunkposition); TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.get(chunkposition);
@ -325,7 +255,7 @@
} }
/** /**
@@ -925,7 +1023,7 @@ @@ -925,7 +1014,7 @@
if (this.isChunkLoaded) if (this.isChunkLoaded)
{ {
@ -334,7 +264,7 @@
} }
} }
@@ -940,7 +1038,8 @@ @@ -940,7 +1029,8 @@
par4TileEntity.yCoord = par2; par4TileEntity.yCoord = par2;
par4TileEntity.zCoord = this.zPosition * 16 + par3; par4TileEntity.zCoord = this.zPosition * 16 + par3;
@ -344,7 +274,7 @@
{ {
if (this.chunkTileEntityMap.containsKey(chunkposition)) if (this.chunkTileEntityMap.containsKey(chunkposition))
{ {
@@ -982,6 +1081,7 @@ @@ -982,6 +1072,7 @@
{ {
this.worldObj.addLoadedEntities(this.entityLists[i]); this.worldObj.addLoadedEntities(this.entityLists[i]);
} }
@ -352,7 +282,7 @@
} }
/** /**
@@ -1002,6 +1102,7 @@ @@ -1002,6 +1093,7 @@
{ {
this.worldObj.unloadEntities(this.entityLists[i]); this.worldObj.unloadEntities(this.entityLists[i]);
} }
@ -360,7 +290,7 @@
} }
/** /**
@@ -1018,8 +1119,8 @@ @@ -1018,8 +1110,8 @@
*/ */
public void getEntitiesWithinAABBForEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector) public void getEntitiesWithinAABBForEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector)
{ {
@ -371,7 +301,7 @@
if (i < 0) if (i < 0)
{ {
@@ -1068,8 +1169,8 @@ @@ -1068,8 +1160,8 @@
*/ */
public void getEntitiesOfTypeWithinAAAB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector) public void getEntitiesOfTypeWithinAAAB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector)
{ {
@ -382,7 +312,7 @@
if (i < 0) if (i < 0)
{ {
@@ -1252,6 +1353,15 @@ @@ -1252,6 +1344,15 @@
*/ */
public void fillChunk(byte[] par1ArrayOfByte, int par2, int par3, boolean par4) public void fillChunk(byte[] par1ArrayOfByte, int par2, int par3, boolean par4)
{ {
@ -398,7 +328,7 @@
int k = 0; int k = 0;
boolean flag1 = !this.worldObj.provider.hasNoSky; boolean flag1 = !this.worldObj.provider.hasNoSky;
int l; int l;
@@ -1352,12 +1462,26 @@ @@ -1352,12 +1453,26 @@
} }
this.generateHeightMap(); this.generateHeightMap();
@ -429,7 +359,7 @@
} }
} }
@@ -1466,4 +1590,18 @@ @@ -1466,4 +1581,18 @@
} }
} }
} }