From: <Mee...@us...> - 2012-01-01 16:41:44
|
Revision: 3730 http://sc2.svn.sourceforge.net/sc2/?rev=3730&view=rev Author: Meep-Eep Date: 2012-01-01 16:41:38 +0000 (Sun, 01 Jan 2012) Log Message: ----------- More DoModifyShips() cleanups. Modified Paths: -------------- trunk/sc2/src/uqm/shipyard.c Modified: trunk/sc2/src/uqm/shipyard.c =================================================================== --- trunk/sc2/src/uqm/shipyard.c 2012-01-01 01:59:12 UTC (rev 3729) +++ trunk/sc2/src/uqm/shipyard.c 2012-01-01 16:41:38 UTC (rev 3730) @@ -931,6 +931,36 @@ } } +// Helper function for DoModifyShips(), called when the player presses +// 'select' or 'cancel' after selling all the crew. +static void +DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip) +{ + RECT r; + SHIP_FRAGMENT *StarShipPtr = + LockShipFrag (&GLOBAL (built_ship_q), hStarShip); + + SetFlashRect (NULL); + UnlockMutex (GraphicsLock); + ShowCombatShip (pMS, pMS->CurState, StarShipPtr); + LockMutex (GraphicsLock); + + UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); + + RemoveQueue (&GLOBAL (built_ship_q), hStarShip); + FreeShipFrag (&GLOBAL (built_ship_q), hStarShip); + // refresh SIS display + DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA); + + r.corner.x = pMS->flash_rect0.corner.x; + r.corner.y = pMS->flash_rect0.corner.y; + r.extent.width = SHIP_WIN_WIDTH; + r.extent.height = SHIP_WIN_HEIGHT; + + SetContext (SpaceContext); + SetFlashRect (&r); +} + /* in this routine, the least significant byte of pMS->CurState is used * to store the current selected ship index * a special case for the row is hi-nibble == -1 (0xf), which specifies @@ -1076,32 +1106,22 @@ if ((pMS->delta_item & MODIFY_CREW_FLAG) && hStarShip != 0) { + // Pressing the select or cancel button in crew edit + // mode for an escort ship. SHIP_FRAGMENT *StarShipPtr = LockShipFrag ( &GLOBAL (built_ship_q), hStarShip); - if (StarShipPtr->crew_level == 0) + COUNT crew_level = StarShipPtr->crew_level; + UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); + + if (crew_level == 0) { - SetFlashRect (NULL); - UnlockMutex (GraphicsLock); - ShowCombatShip (pMS, pMS->CurState, StarShipPtr); - LockMutex (GraphicsLock); - UnlockShipFrag (&GLOBAL (built_ship_q), - hStarShip); - RemoveQueue (&GLOBAL (built_ship_q), hStarShip); - FreeShipFrag (&GLOBAL (built_ship_q), hStarShip); - // refresh SIS display - DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, - UNDEFINED_DELTA); - r.corner.x = pMS->flash_rect0.corner.x; - r.corner.y = pMS->flash_rect0.corner.y; - r.extent.width = SHIP_WIN_WIDTH; - r.extent.height = SHIP_WIN_HEIGHT; - SetContext (SpaceContext); - SetFlashRect (&r); + // Scrap escort ship, then exiting crew edit + // mode. + DMS_ScrapEscortShip (pMS, hStarShip); } else { - UnlockShipFrag (&GLOBAL (built_ship_q), - hStarShip); + // Just exiting escort ship crew edit mode. } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |