Skip to content

Commit

Permalink
Fixed new game crash in arcade/multiplayer games related to improper …
Browse files Browse the repository at this point in the history
…level number handling.
  • Loading branch information
forteri76 committed Jun 9, 2014
1 parent f472e85 commit c21d5fc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 90 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.jfedor.frozenbubble"
android:versionCode="33"
android:versionName="3.0">
android:versionCode="34"
android:versionName="3.1">

<supports-screens
android:smallScreens="true"
Expand Down
117 changes: 30 additions & 87 deletions src/org/jfedor/frozenbubble/GameView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,6 @@ public void cleanUp() {
mFrozenGame1 = null;
mFrozenGame2 = null;

boolean imagesScaled = (mBackgroundOrig == mBackground.bmp);
mBackgroundOrig.recycle();
mBackgroundOrig = null;

Expand Down Expand Up @@ -1058,6 +1057,8 @@ public void cleanUp() {
mCompressorOrig = null;
mLifeOrig.recycle();
mLifeOrig = null;
mFontImageOrig.recycle();
mFontImageOrig = null;
if (mBananaOrig != null) {
mBananaOrig.recycle();
}
Expand All @@ -1067,116 +1068,58 @@ public void cleanUp() {
}
mTomatoOrig = null;

if (imagesScaled) {
mBackground.bmp.recycle();
for (int i = 0; i < mBubbles.length; i++) {
mBubbles[i].bmp.recycle();
}

for (int i = 0; i < mBubblesBlind.length; i++) {
mBubblesBlind[i].bmp.recycle();
}

for (int i = 0; i < mFrozenBubbles.length; i++) {
mFrozenBubbles[i].bmp.recycle();
}

for (int i = 0; i < mTargetedBubbles.length; i++) {
mTargetedBubbles[i].bmp.recycle();
}

mBubbleBlink.bmp.recycle();
mGameWon.bmp.recycle();
mGameLost.bmp.recycle();
mGamePaused.bmp.recycle();
mHurry.bmp.recycle();
if (mPauseButton != null) {
mPauseButton.bmp.recycle();
}
if (mPlayButton != null) {
mPlayButton.bmp.recycle();
}
mPenguins.bmp.recycle();
if (mPenguins2 != null) {
mPenguins2.bmp.recycle();
}
mCompressorHead.bmp.recycle();
mCompressor.bmp.recycle();
mLife.bmp.recycle();
if (mBanana != null) {
mBanana.bmp.recycle();
}
if (mTomato != null) {
mTomato.bmp.recycle();
}
/*
* All the scalable bitmaps are located within the image list,
* so recycling all the bitmaps in this list ensures they are
* all recycled.
*/
int size = mImageList.size();
while (size > 0) {
BmpWrap bmpWrap = mImageList.elementAt(--size);
bmpWrap.bmp.recycle();
bmpWrap.bmp = null;
}
mBackground.bmp = null;
mImageList.clear();
mImageList = null;

mBackground = null;

for (int i = 0; i < mBubbles.length; i++) {
mBubbles[i].bmp = null;
mBubbles[i] = null;
}
mBubbles = null;

for (int i = 0; i < mBubblesBlind.length; i++) {
mBubblesBlind[i].bmp = null;
mBubblesBlind[i] = null;
}
mBubblesBlind = null;

for (int i = 0; i < mFrozenBubbles.length; i++) {
mFrozenBubbles[i].bmp = null;
mFrozenBubbles[i] = null;
}
mFrozenBubbles = null;

for (int i = 0; i < mTargetedBubbles.length; i++) {
mTargetedBubbles[i].bmp = null;
mTargetedBubbles[i] = null;
}
mTargetedBubbles = null;

mBubbleBlink.bmp = null;
mBubbleBlink = null;
mGameWon.bmp = null;
mGameWon = null;
mGameLost.bmp = null;
mGameLost = null;
mGamePaused.bmp = null;
mGamePaused = null;
mHurry.bmp = null;
mHurry = null;
if (mPauseButton != null) {
mPauseButton.bmp = null;
}
mPauseButton = null;
if (mPlayButton != null) {
mPlayButton.bmp = null;
}
mPlayButton = null;
mPenguins.bmp = null;
mPenguins = null;
if (mPenguins2 != null) {
mPenguins2.bmp = null;
}
mPenguins2 = null;
mCompressorHead.bmp = null;
mBubbleBlink = null;
mGameWon = null;
mGameLost = null;
mGamePaused = null;
mHurry = null;
mPauseButton = null;
mPlayButton = null;
mPenguins = null;
mPenguins2 = null;
mCompressorHead = null;
mCompressor.bmp = null;
mCompressor = null;
mLife.bmp = null;
mLife = null;
if (mBanana != null) {
mBanana.bmp = null;
}
mBanana = null;
if (mTomato != null) {
mTomato.bmp = null;
}
mTomato = null;
mCompressor = null;
mLife = null;
mFontImage = null;
mBanana = null;
mTomato = null;

mImageList = null;
mSoundManager.cleanUp();
mSoundManager = null;
mLevelManager = null;
Expand Down Expand Up @@ -1744,7 +1687,7 @@ public void newGame(boolean firstLevel) {
else {
malusBar1 = null;
malusBar2 = null;
if (firstLevel) {
if (!FrozenBubble.arcadeGame && firstLevel && (numPlayers == 1)) {
mLevelManager.goToFirstLevel();
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/org/jfedor/frozenbubble/LevelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ public void goToNextLevel() {
}

public void goToFirstLevel() {
currentLevel = 0;
if (!randomMode) {
currentLevel = 0;
}
}

public int getLevelIndex() {
Expand Down

0 comments on commit c21d5fc

Please sign in to comment.