From 4361372009949f7c4fcc3c7086ee96ce20c742e4 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Thu, 3 Oct 2002 07:15:51 +0000 Subject: [PATCH] Shipyard animations no longer hang the game git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@97 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/shipyard.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sc2/src/sc2code/shipyard.c b/sc2/src/sc2code/shipyard.c index 7af0ee030..f4129290f 100644 --- a/sc2/src/sc2code/shipyard.c +++ b/sc2/src/sc2code/shipyard.c @@ -186,6 +186,7 @@ DrawRaceStrings (BYTE NewRaceItem) #define SHIP_WIN_WIDTH 34 #define SHIP_WIN_HEIGHT (SHIP_WIN_WIDTH + 6) +#define SHIP_WIN_FRAMES ((SHIP_WIN_WIDTH >> 1) + 1) static void ShowShipCrew (SHIP_FRAGMENTPTR StarShipPtr, PRECT pRect) @@ -368,6 +369,7 @@ ShowCombatShip (COUNT which_window, SHIP_FRAGMENTPTR YankedStarShipPtr) DWORD TimeIn; RECT r; CONTEXT OldContext; + int j; SetSemaphore (GraphicsSem); OldContext = SetContext (OffScreenContext); @@ -380,10 +382,13 @@ ShowCombatShip (COUNT which_window, SHIP_FRAGMENTPTR YankedStarShipPtr) r.extent.height = SHIP_WIN_HEIGHT; ButtonState = AnyButtonPress (FALSE) ? 1 : 0; TimeIn = GetTimeCounter (); - do + + for (j = 0; (j < SHIP_WIN_FRAMES) && !AllDoorsFinished; j++) { + ClearSemaphore (GraphicsSem); SleepThreadUntil (TimeIn + 5); TimeIn = GetTimeCounter (); + SetSemaphore (GraphicsSem); BatchGraphics (); StartFinalPass: pship_win_info = &ship_win_info[0]; @@ -399,8 +404,11 @@ StartFinalPass: if (YankedStarShipPtr == 0) AllDoorsFinished = TRUE; else + { pship_win_info->lfdoor_s.origin.x = pship_win_info->rtdoor_s.origin.x = 0; + AllDoorsFinished = TRUE; + } goto StartFinalPass; } @@ -436,7 +444,7 @@ StartFinalPass: } UnbatchGraphics (); - } while (!AllDoorsFinished); + } SetContextClipRect (NULL_PTR); SetContext (OldContext); @@ -690,7 +698,7 @@ DoModifyShips (INPUT_STATE InputState, PMENU_STATE pMS) goto ChangeFlashRect; } else if (InputState & (DEVICE_BUTTON1 | DEVICE_BUTTON2)) - { + { if (!(pMS->delta_item ^= MODIFY_CREW_FLAG)) goto ChangeFlashRect; else if (hStarShip == 0) @@ -837,10 +845,10 @@ DoModifyShips (INPUT_STATE InputState, PMENU_STATE pMS) crew_bought -= crew_delta; } ResUnits += crew_bought * GLOBAL (CrewCost); - + SetFlashRect (NULL_PTR, (FRAME)0); - ClearSemaphore (GraphicsSem); - ShowCombatShip ((COUNT)pMS->CurState, StarShipPtr); + ClearSemaphore (GraphicsSem); + ShowCombatShip ((COUNT)pMS->CurState, StarShipPtr); SetSemaphore (GraphicsSem); pMS->flash_rect0.extent.width = SHIP_WIN_WIDTH; SetFlashRect (&pMS->flash_rect0, (FRAME)0);