v0.4.3: fixed a bunch of crash bugs

This commit is contained in:
Evan Debenham 2016-10-01 02:38:24 -04:00
parent 794648fa21
commit e3b0720de9
4 changed files with 45 additions and 22 deletions

View File

@ -32,18 +32,20 @@ public class Vertexbuffer {
private FloatBuffer vertices;
private int updateStart, updateEnd;
private static ArrayList<Vertexbuffer> buffers = new ArrayList<>();
private static final ArrayList<Vertexbuffer> buffers = new ArrayList<>();
public Vertexbuffer( FloatBuffer vertices ) {
int[] ptr = new int[1];
GLES20.glGenBuffers( 1, ptr, 0 );
id = ptr[0];
synchronized (buffers) {
int[] ptr = new int[1];
GLES20.glGenBuffers(1, ptr, 0);
id = ptr[0];
this.vertices = vertices;
buffers.add(this);
this.vertices = vertices;
buffers.add(this);
updateStart = 0;
updateEnd = vertices.limit();
updateStart = 0;
updateEnd = vertices.limit();
}
}
//For flagging the buffer for a full update without changing anything
@ -96,14 +98,18 @@ public class Vertexbuffer {
}
public void delete(){
GLES20.glDeleteBuffers(1, new int[]{id}, 0);
buffers.remove(this);
synchronized (buffers) {
GLES20.glDeleteBuffers(1, new int[]{id}, 0);
buffers.remove(this);
}
}
public static void refreshAllBuffers(){
for (Vertexbuffer buf : buffers) {
buf.updateVertices();
buf.updateGLData();
synchronized (buffers) {
for (Vertexbuffer buf : buffers) {
buf.updateVertices();
buf.updateGLData();
}
}
}

View File

@ -245,7 +245,10 @@ public class Tilemap extends Visual {
while(bottomRight >= topLeft && bufferPositions[bottomRight] == -1)
bottomRight--;
length = bufferPositions[bottomRight] - bufferPositions[topLeft] + 1;
if (topLeft >= bufferPositions.length || bottomRight <= 0)
length = 0;
else
length = bufferPositions[bottomRight] - bufferPositions[topLeft] + 1;
}
if (camX >= mapWidth

View File

@ -336,7 +336,8 @@ public class Hero extends Char {
}
if (dmg < 0) dmg = 0;
if (subClass == HeroSubClass.BERSERKER){
dmg = Buff.affect(this, Berserk.class).damageFactor(dmg);
berserk = Buff.affect(this, Berserk.class);
dmg = berserk.damageFactor(dmg);
}
return buff( Fury.class ) != null ? (int)(dmg * 1.5f) : dmg;
}
@ -1168,7 +1169,10 @@ public class Hero extends Char {
HornOfPlenty.hornRecharge horn = buff(HornOfPlenty.hornRecharge.class);
if (horn != null) horn.gainCharge(percent);
if (subClass == HeroSubClass.BERSERKER) Buff.affect(this, Berserk.class).recover(percent);
if (subClass == HeroSubClass.BERSERKER){
berserk = Buff.affect(this, Berserk.class);
berserk.recover(percent);
}
boolean levelUp = false;
while (this.exp >= maxExp()) {
@ -1370,13 +1374,17 @@ public class Hero extends Char {
Dungeon.deleteGame( Dungeon.hero.heroClass, true );
}
//effectively cache this buff to prevent having to call buff(Berserk.class) a bunch.
//This is relevant because we call isAlive during drawing, which has both performance
//and concurrent modification implications if that method calls buff(Berserk.class)
private Berserk berserk;
@Override
public boolean isAlive() {
if (subClass == HeroSubClass.BERSERKER){
Berserk berserk = buff(Berserk.class);
if (berserk != null && berserk.berserking()){
return true;
}
if (subClass == HeroSubClass.BERSERKER
&& berserk != null
&& berserk.berserking()){
return true;
}
return super.isAlive();
}

View File

@ -145,6 +145,11 @@ public class BuffIndicator extends Component {
super.updateValues( progress );
image.scale.set( 1 + 5 * progress );
};
@Override
protected void onComplete() {
image.killAndErase();
}
} );
}
}
@ -176,7 +181,8 @@ public class BuffIndicator extends Component {
@Override
protected void onClick() {
GameScene.show(new WndInfoBuff(buff));
if (buff.icon() != NONE)
GameScene.show(new WndInfoBuff(buff));
}
}