Skip to content

Commit

Permalink
SDL2: Fixes in the "end of game" turboMode
Browse files Browse the repository at this point in the history
  • Loading branch information
frranck committed Jan 14, 2019
1 parent f7dba25 commit 82feec9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
22 changes: 21 additions & 1 deletion ai/MrboomHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ int nbLives(int player)
}
}

bool isDead(int player)
{
return(m.vie[player] == 16);
}

bool isAlive(int player)
{
return(m.vie[player] == 1);
Expand Down Expand Up @@ -531,7 +536,7 @@ bool isSuicideOK(int player)
return((nbLivesFriends > 1) && (nbLivesEnemies == 1));
}

bool someHumanPlayersAlive()
bool someHumanPlayersAlive() // About to die players are considered dead
{
for (int i = 0; i < numberOfPlayers(); i++)
{
Expand All @@ -545,3 +550,18 @@ bool someHumanPlayersAlive()
}
return(false);
}

bool someHumanPlayersNotDead() // About to die players are considered alive
{
for (int i = 0; i < numberOfPlayers(); i++)
{
if (isAIActiveForPlayer(i) == false)
{
if (!isDead(i))
{
return(true);
}
}
}
return(false);
}
1 change: 1 addition & 0 deletions ai/MrboomHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ enum Bonus
};

bool someHumanPlayersAlive();
bool someHumanPlayersNotDead();
bool isInTheApocalypse();
bool isAlive(int player);
bool isAIActiveForPlayer(int player);
Expand Down
4 changes: 2 additions & 2 deletions sdl2/sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,13 @@ loop()
{
anyButtonPushedMaskSave = 0;
}
if (someHumanPlayersAlive())
if (someHumanPlayersNotDead())
{
anyButtonPushedMaskSave = anyButtonPushedMask;
}
else
{
if (isGameActive())
if (!isAboutToWin() && isGameActive())
{
if (anyButtonPushedMaskSave != anyButtonPushedMask) // to avoid speeding straight away when still holding current keys
{
Expand Down

0 comments on commit 82feec9

Please sign in to comment.