From dc94da2cc4c9f66269b2043bff85fe4edfa15a54 Mon Sep 17 00:00:00 2001 From: Meep-Eep Date: Sat, 5 May 2007 17:11:24 +0000 Subject: [PATCH] Fix assertion when ending the battle with a simultaneous death. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2752 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 ++ sc2/src/sc2code/battle.c | 29 ++++++++++++++++++----------- sc2/src/sc2code/pickmele.c | 4 ++-- sc2/src/sc2code/pickmele.h | 1 + 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index a51eec856..fb4c04b87 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Ending the battle with a simultaneous death no longer triggers an + assertion - SvdB - Concurrent supermelee ship selection - SvdB - New generic, unthreaded flashing code - SvdB - Cleanup of 3DO ship spin support; spin speech works now - Alex diff --git a/sc2/src/sc2code/battle.c b/sc2/src/sc2code/battle.c index 5911aadfc..1db6e8b2f 100644 --- a/sc2/src/sc2code/battle.c +++ b/sc2/src/sc2code/battle.c @@ -458,21 +458,28 @@ Battle (void) LockMutex (GraphicsLock); AbortBattle: - if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE && - (GLOBAL (CurrentActivity) & CHECK_ABORT)) + if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) { - // Do not return to the main menu when a game is aborted, - // (just to the supermelee menu). + if (GLOBAL (CurrentActivity) & CHECK_ABORT) + { + // Do not return to the main menu when a game is aborted, + // (just to the supermelee menu). #ifdef NETPLAY - UnlockMutex (GraphicsLock); - waitResetConnections(NetState_inSetup); - // A connection may already be in inSetup (set from - // GetMeleeStarship). This is not a problem, although - // it will generate a warning in debug mode. - LockMutex (GraphicsLock); + UnlockMutex (GraphicsLock); + waitResetConnections(NetState_inSetup); + // A connection may already be in inSetup (set from + // GetMeleeStarship). This is not a problem, although + // it will generate a warning in debug mode. + LockMutex (GraphicsLock); #endif - GLOBAL (CurrentActivity) &= ~CHECK_ABORT; + GLOBAL (CurrentActivity) &= ~CHECK_ABORT; + } + else + { + // Show the result of the battle. + MeleeGameOver (); + } } #ifdef NETPLAY diff --git a/sc2/src/sc2code/pickmele.c b/sc2/src/sc2code/pickmele.c index 0c70e0328..8983d67a9 100644 --- a/sc2/src/sc2code/pickmele.c +++ b/sc2/src/sc2code/pickmele.c @@ -469,7 +469,7 @@ DrawPickMeleeFrame (COUNT which_player) } // Pre: caller holds the graphics lock. -static void +void MeleeGameOver (void) { COUNT playerI; @@ -523,13 +523,13 @@ MeleeShipDeath (STARSHIP *ship, COUNT which_player) { if (battle_counter[0] == 0 || battle_counter[1] == 0) { // One side is out of ships. Game over. - MeleeGameOver (); return FALSE; } return TRUE; } +// Post: the NetState for all players is NetState_interBattle static BOOLEAN GetMeleeStarShips (COUNT playerMask, HSTARSHIP *ships) { diff --git a/sc2/src/sc2code/pickmele.h b/sc2/src/sc2code/pickmele.h index e7062f09f..728aefaf1 100644 --- a/sc2/src/sc2code/pickmele.h +++ b/sc2/src/sc2code/pickmele.h @@ -21,6 +21,7 @@ #include "libs/compiler.h" BOOLEAN MeleeShipDeath (STARSHIP *ship, COUNT which_player); +void MeleeGameOver (void); BOOLEAN GetInitialMeleeStarShips (HSTARSHIP *result); BOOLEAN GetNextMeleeStarShip (COUNT which_player, HSTARSHIP *result);