Remove all iterator concurrent checks.
This commit is contained in:
parent
d81ee2a126
commit
f977a3d3b5
BIN
Meteo_Engine.jar
BIN
Meteo_Engine.jar
Binary file not shown.
@ -38,7 +38,10 @@ public class BlockClump {
|
|||||||
for (int i=0;i<collisionColumnRanges.length;i++) {
|
for (int i=0;i<collisionColumnRanges.length;i++) {
|
||||||
collisionColumnRanges[i] = new int[]{-1,-1};
|
collisionColumnRanges[i] = new int[]{-1,-1};
|
||||||
}
|
}
|
||||||
for (Block b : blocks) {updateBlockCollisionRangeWithBlock(b);}
|
for (int i=0;i<blocks.size();i++) {
|
||||||
|
Block b = blocks.get(i);
|
||||||
|
updateBlockCollisionRangeWithBlock(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void addBlock(Block...blocks) {
|
public void addBlock(Block...blocks) {
|
||||||
//Adds the block to the strucutre. Update collision column ranges to reflect the new bounds.
|
//Adds the block to the strucutre. Update collision column ranges to reflect the new bounds.
|
||||||
@ -55,7 +58,8 @@ public class BlockClump {
|
|||||||
updateBlockCollision();
|
updateBlockCollision();
|
||||||
}
|
}
|
||||||
public void drawBlocks(Graphics g, int originX, int originY, int block_width, int block_height, Block selectedBlock) {
|
public void drawBlocks(Graphics g, int originX, int originY, int block_width, int block_height, Block selectedBlock) {
|
||||||
for (Block b : blocks) {
|
for (int i=0;i<blocks.size();i++) {
|
||||||
|
Block b = blocks.get(i);
|
||||||
b.draw(g,originX+x,originY-y,block_width,block_height,launched,selectedBlock!=null&&selectedBlock.equals(b));
|
b.draw(g,originX+x,originY-y,block_width,block_height,launched,selectedBlock!=null&&selectedBlock.equals(b));
|
||||||
if (Meteo.DEBUG_DRAWING==DebugMode.MODE2) {
|
if (Meteo.DEBUG_DRAWING==DebugMode.MODE2) {
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
@ -105,10 +109,12 @@ public class BlockClump {
|
|||||||
return "BlockClump [blocks=" + blocks + ", x=" + x + ", y=" + y + ", yspd=" + yspd + "]";
|
return "BlockClump [blocks=" + blocks + ", x=" + x + ", y=" + y + ", yspd=" + yspd + "]";
|
||||||
}
|
}
|
||||||
public static void drawDebugBlockClumps(Graphics g, int originX, int originY, int block_width, int block_height, List<BlockClump> blockData) {
|
public static void drawDebugBlockClumps(Graphics g, int originX, int originY, int block_width, int block_height, List<BlockClump> blockData) {
|
||||||
for (BlockClump bc : blockData) {
|
for (int i=0;i<blockData.size();i++) {
|
||||||
|
BlockClump bc = blockData.get(i);
|
||||||
bc.drawClumpOutlines(g,originX,originY,block_width,block_height);
|
bc.drawClumpOutlines(g,originX,originY,block_width,block_height);
|
||||||
}
|
}
|
||||||
for (BlockClump bc : blockData) {
|
for (int i=0;i<blockData.size();i++) {
|
||||||
|
BlockClump bc = blockData.get(i);
|
||||||
bc.drawClumpDots(g,originX,originY,block_width,block_height);
|
bc.drawClumpDots(g,originX,originY,block_width,block_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,13 +58,15 @@ public class Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
outerloop:
|
outerloop:
|
||||||
for (BlockClump blocks : blockData) {
|
for (int i=0;i<blockData.size();i++) {
|
||||||
|
BlockClump blocks = blockData.get(i);
|
||||||
DestroyOutsideBlocks(blocks);
|
DestroyOutsideBlocks(blocks);
|
||||||
if (checkForMatches(blocks)) {continue;}
|
if (checkForMatches(blocks)) {continue;}
|
||||||
double FUTURE_FALL_POSITION = blocks.y+blocks.yspd+gravity;
|
double FUTURE_FALL_POSITION = blocks.y+blocks.yspd+gravity;
|
||||||
for (int x=0;x<width;x++) {
|
for (int x=0;x<width;x++) {
|
||||||
if (blocks.collisionColumnRanges[x][0]!=-1) {
|
if (blocks.collisionColumnRanges[x][0]!=-1) {
|
||||||
for (BlockClump blocks2 : blockData) {
|
for (int j=0;j<blockData.size();j++) {
|
||||||
|
BlockClump blocks2 = blockData.get(j);
|
||||||
if (!blocks.equals(blocks2)&&blocks2.collisionColumnRanges[x][1]!=-1) {
|
if (!blocks.equals(blocks2)&&blocks2.collisionColumnRanges[x][1]!=-1) {
|
||||||
if (FUTURE_FALL_POSITION<blocks2.y) {
|
if (FUTURE_FALL_POSITION<blocks2.y) {
|
||||||
if (FUTURE_FALL_POSITION+blocks.collisionColumnRanges[x][1]*block_height>blocks2.y+(blocks2.collisionColumnRanges[x][0]+1)*block_height) {
|
if (FUTURE_FALL_POSITION+blocks.collisionColumnRanges[x][1]*block_height>blocks2.y+(blocks2.collisionColumnRanges[x][0]+1)*block_height) {
|
||||||
@ -124,7 +126,8 @@ public class Board {
|
|||||||
List<BlockClump> groundedClumps = blockData.stream().filter((cl)->cl.y==0).collect(Collectors.toList());
|
List<BlockClump> groundedClumps = blockData.stream().filter((cl)->cl.y==0).collect(Collectors.toList());
|
||||||
if (groundedClumps.size()>1) {
|
if (groundedClumps.size()>1) {
|
||||||
BlockClump base = groundedClumps.remove(0);
|
BlockClump base = groundedClumps.remove(0);
|
||||||
for (BlockClump bc : groundedClumps) {
|
for (int i=0;i<groundedClumps.size();i++) {
|
||||||
|
BlockClump bc = groundedClumps.get(i);
|
||||||
base.addBlock(bc.getBlocks().toArray(new Block[bc.getBlocks().size()]));
|
base.addBlock(bc.getBlocks().toArray(new Block[bc.getBlocks().size()]));
|
||||||
}
|
}
|
||||||
blockClumpDeleteList.addAll(groundedClumps);
|
blockClumpDeleteList.addAll(groundedClumps);
|
||||||
@ -149,7 +152,8 @@ public class Board {
|
|||||||
int minY=Integer.MAX_VALUE;
|
int minY=Integer.MAX_VALUE;
|
||||||
List<Block> newClumpBlocks = new ArrayList<Block>();
|
List<Block> newClumpBlocks = new ArrayList<Block>();
|
||||||
newClumpBlocks.addAll(markedBlocks);
|
newClumpBlocks.addAll(markedBlocks);
|
||||||
for (Block b : markedBlocks) {
|
for (int i=0;i<markedBlocks.size();i++) {
|
||||||
|
Block b = markedBlocks.get(i);
|
||||||
b.state = BlockState.IGNITED;
|
b.state = BlockState.IGNITED;
|
||||||
//All blocks above marked blocks now join the clump.
|
//All blocks above marked blocks now join the clump.
|
||||||
newClumpBlocks.addAll(blocks.getSortedBlocksOnCol(b.x).stream().filter((block)->!newClumpBlocks.contains(block)&&block.y>b.y).collect(Collectors.toList()));
|
newClumpBlocks.addAll(blocks.getSortedBlocksOnCol(b.x).stream().filter((block)->!newClumpBlocks.contains(block)&&block.y>b.y).collect(Collectors.toList()));
|
||||||
@ -157,7 +161,8 @@ public class Board {
|
|||||||
}
|
}
|
||||||
//For now just get rid of them.
|
//For now just get rid of them.
|
||||||
RemoveBlocks(blocks,newClumpBlocks.toArray(new Block[newClumpBlocks.size()]));
|
RemoveBlocks(blocks,newClumpBlocks.toArray(new Block[newClumpBlocks.size()]));
|
||||||
for (Block b : newClumpBlocks) {
|
for (int i=0;i<newClumpBlocks.size();i++) {
|
||||||
|
Block b = newClumpBlocks.get(i);
|
||||||
b.y-=minY;
|
b.y-=minY;
|
||||||
}
|
}
|
||||||
blockClumpAddList.add(
|
blockClumpAddList.add(
|
||||||
@ -210,7 +215,8 @@ public class Board {
|
|||||||
return markedBlocks;
|
return markedBlocks;
|
||||||
}
|
}
|
||||||
private void CombineAToB(BlockClump A, BlockClump B) {
|
private void CombineAToB(BlockClump A, BlockClump B) {
|
||||||
for (Block b : A.getBlocks()) {
|
for (int i=0;i<A.getBlocks().size();i++) {
|
||||||
|
Block b = A.getBlocks().get(i);
|
||||||
b.y = B.collisionColumnRanges[b.x][1]+1;
|
b.y = B.collisionColumnRanges[b.x][1]+1;
|
||||||
B.addBlock(b);
|
B.addBlock(b);
|
||||||
}
|
}
|
||||||
@ -226,7 +232,8 @@ public class Board {
|
|||||||
SplitBlockClump(blocks);
|
SplitBlockClump(blocks);
|
||||||
}
|
}
|
||||||
if (blocks.launched<=0) {
|
if (blocks.launched<=0) {
|
||||||
for (Block b : blocks.getBlocks()) {
|
for (int i=0;i<blocks.getBlocks().size();i++) {
|
||||||
|
Block b = blocks.getBlocks().get(i);
|
||||||
if (b.state==BlockState.IGNITED) {
|
if (b.state==BlockState.IGNITED) {
|
||||||
b.state=STARTINGSTATES[(int)(Meteo.r.nextInt(3))];
|
b.state=STARTINGSTATES[(int)(Meteo.r.nextInt(3))];
|
||||||
}
|
}
|
||||||
@ -251,7 +258,8 @@ public class Board {
|
|||||||
final int DRAW_STARTY = (int)(y + block_height*((double)height/2));
|
final int DRAW_STARTY = (int)(y + block_height*((double)height/2));
|
||||||
final int DRAW_ENDX = (int)(x + block_width*((double)width/2));
|
final int DRAW_ENDX = (int)(x + block_width*((double)width/2));
|
||||||
|
|
||||||
for (BlockClump bc : blockData) {
|
for (int i=0;i<blockData.size();i++) {
|
||||||
|
BlockClump bc = blockData.get(i);
|
||||||
bc.drawBlocks(g,DRAW_STARTX,DRAW_STARTY,block_width,block_height,clickBlock);
|
bc.drawBlocks(g,DRAW_STARTX,DRAW_STARTY,block_width,block_height,clickBlock);
|
||||||
}
|
}
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
@ -271,8 +279,10 @@ public class Board {
|
|||||||
clickBlock=null;
|
clickBlock=null;
|
||||||
clumpClickId=null;
|
clumpClickId=null;
|
||||||
outer:
|
outer:
|
||||||
for (BlockClump bc : blockData) {
|
for (int i=0;i<blockData.size();i++) {
|
||||||
for (Block b : bc.getBlocks()) {
|
BlockClump bc = blockData.get(i);
|
||||||
|
for (int j=0;j<bc.getBlocks().size();j++) {
|
||||||
|
Block b = bc.getBlocks().get(j);
|
||||||
if (new Rectangle(b.draw_x,b.draw_y,block_width,block_height).contains(e.getPoint())) {
|
if (new Rectangle(b.draw_x,b.draw_y,block_width,block_height).contains(e.getPoint())) {
|
||||||
clickBlock=b;
|
clickBlock=b;
|
||||||
clumpClickId=bc;
|
clumpClickId=bc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user