diff -r 8df58d8c99e8 -r b3ffff030d5c commands/snake/snake.cpp --- a/commands/snake/snake.cpp Tue Oct 26 15:36:30 2010 +0100 +++ b/commands/snake/snake.cpp Thu Oct 28 16:54:54 2010 +0100 @@ -439,8 +439,10 @@ void CCmdSnake::PlaceBait() { TBool ok; + TInt attempts = 0; do { + attempts++; ok = ETrue; iBait.iX = Math::Rand(iRandomSeed) % iBoardSize.iWidth; iBait.iY = Math::Rand(iRandomSeed) % iBoardSize.iHeight; @@ -453,6 +455,7 @@ if (iSnake[i] == iBait) ok = EFalse; } } + if (attempts >= iBoardSize.iWidth * iBoardSize.iHeight) return; // Snake has filled the entire board! Time to bail (the snake will run into itself right after we return here) } while (!ok); iCons.SetCursorPosAbs(iBait); iCons.Write(iUnicode ? KUnicodeBait : KBait);