From f8ee727c28f641c844b56c4126888dcf83d6caa2 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Fri, 29 Aug 2003 10:16:20 +0000 Subject: [PATCH] Ships aren't sold without confirmation anymore (Bug 413), from Paxtez git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1142 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 + sc2/WhatsNew | 4 +- sc2/src/sc2code/shipyard.c | 122 ++++++++++++++++--------------------- 3 files changed, 59 insertions(+), 69 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index f5ab7376a..8781e914f 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.3: +- Ships are not sold unless you set their crew level to SCRAP, (bug + #413), from Paxtez - Prevent Syreen crew above 12 getting thrown out the airlock in Roster screen (bug #184); from chmmravatar, Alex - Lander report messages now use the entire panel (bug #36), from chmmravatar diff --git a/sc2/WhatsNew b/sc2/WhatsNew index 6344d6e11..4218bd15e 100644 --- a/sc2/WhatsNew +++ b/sc2/WhatsNew @@ -17,7 +17,9 @@ Changes are broadly classified into the following categories: NEW FEATURES -- PC-style shipyard, complete with animated power lines +- PC-style shipyard graphics, complete with animated power lines +- Selling ships in the shipyards has slightly different controls + that make it harder to sell ships accidentally - Main menu displays version number - Added a '-g' option to control gamma correction - Planet spin has been improved diff --git a/sc2/src/sc2code/shipyard.c b/sc2/src/sc2code/shipyard.c index 8128cc544..6f78fe84e 100644 --- a/sc2/src/sc2code/shipyard.c +++ b/sc2/src/sc2code/shipyard.c @@ -298,6 +298,8 @@ ShowShipCrew (SHIP_FRAGMENTPTR StarShipPtr, PRECT pRect) if (StarShipPtr->ShipInfo.crew_level >= TemplatePtr->RaceDescPtr->ship_info.crew_level) wsprintf (buf, "%u", StarShipPtr->ShipInfo.crew_level); + else if (StarShipPtr->ShipInfo.crew_level == 0) + wsprintf (buf, "SCRAP"); else wsprintf (buf, "%u/%u", StarShipPtr->ShipInfo.crew_level, @@ -320,7 +322,9 @@ ShowShipCrew (SHIP_FRAGMENTPTR StarShipPtr, PRECT pRect) SetContextForeGroundColor (BLACK_COLOR); DrawFilledRectangle (&r); } - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x00), 0x02)); + SetContextForeGroundColor ((StarShipPtr->ShipInfo.crew_level != 0) ? + (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x00), 0x02)): + (BUILD_COLOR (MAKE_RGB15 (0x12, 0x00, 0x00), 0x2B))); font_DrawText (&t); } @@ -773,9 +777,8 @@ DoModifyShips (PMENU_STATE pMS) DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW); SetSemaphore (GraphicsSem); - DeltaSISGauges ( - UNDEFINED_DELTA, UNDEFINED_DELTA, -((int)ShipCost[Index]) - ); + DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, + -((int)ShipCost[Index])); r.corner.x = pMS->flash_rect0.corner.x; r.corner.y = pMS->flash_rect0.corner.y + pMS->flash_rect0.extent.height - 6; @@ -816,7 +819,25 @@ DoModifyShips (PMENU_STATE pMS) } else if (select || cancel) { - if (!(pMS->delta_item ^= MODIFY_CREW_FLAG)) + + if (StarShipPtr->ShipInfo.crew_level == 0) + { + SetFlashRect (NULL_PTR, (FRAME)0); + ClearSemaphore (GraphicsSem); + ShowCombatShip ((COUNT)pMS->CurState, StarShipPtr); + SetSemaphore (GraphicsSem); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); + RemoveQueue (&GLOBAL (built_ship_q), hStarShip); + FreeStarShip (&GLOBAL (built_ship_q), hStarShip); + 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, (FRAME)0); + pMS->delta_item ^= MODIFY_CREW_FLAG; + } + else if (!(pMS->delta_item ^= MODIFY_CREW_FLAG)) goto ChangeFlashRect; else if (hStarShip == 0) { @@ -846,7 +867,7 @@ DoModifyShips (PMENU_STATE pMS) ); crew_delta = 0; - if (dx < 0 || dy < 0) + if (dy < 0) { if (hStarShip == 0) { @@ -876,17 +897,19 @@ DoModifyShips (PMENU_STATE pMS) TemplatePtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (avail_race_q), hTemplate ); - if (GLOBAL_SIS (ResUnits) >= - (DWORD)GLOBAL (CrewCost) - && StarShipPtr->ShipInfo.crew_level < - StarShipPtr->ShipInfo.max_crew + if (GLOBAL_SIS (ResUnits) >= (DWORD)GLOBAL (CrewCost) && StarShipPtr->ShipInfo.crew_level < + StarShipPtr->ShipInfo.max_crew && + StarShipPtr->ShipInfo.crew_level < TemplatePtr->RaceDescPtr->ship_info.crew_level) { - DeltaSISGauges (0, 0, -GLOBAL (CrewCost)); + if (StarShipPtr->ShipInfo.crew_level > 0) + DeltaSISGauges (0, 0, -GLOBAL (CrewCost)); + else + DeltaSISGauges (UNDEFINED_DELTA,UNDEFINED_DELTA, + -(COUNT)ShipCost[GET_RACE_ID (StarShipPtr)]); ++StarShipPtr->ShipInfo.crew_level; crew_delta = 1; - ShowShipCrew (StarShipPtr, &pMS->flash_rect0); r.corner.x = pMS->flash_rect0.corner.x; r.corner.y = pMS->flash_rect0.corner.y @@ -901,7 +924,7 @@ DoModifyShips (PMENU_STATE pMS) ); } } - else if (dx > 0 || dy > 0) + else if (dy > 0) { crew_bought = (SIZE)MAKE_WORD ( GET_GAME_STATE (CREW_PURCHASED0), @@ -912,7 +935,8 @@ DoModifyShips (PMENU_STATE pMS) if (GetCrewCount ()) { DeltaSISGauges (-1, 0, GLOBAL (CrewCost) - - (crew_bought == CREW_EXPENSE_THRESHOLD ? 2 : 0)); + - (crew_bought == + CREW_EXPENSE_THRESHOLD ? 2 : 0)); crew_delta = -1; GetCPodCapacity (&r.corner); @@ -925,13 +949,20 @@ DoModifyShips (PMENU_STATE pMS) SetContext (SpaceContext); } } - else if (StarShipPtr->ShipInfo.crew_level > 1) + else { - DeltaSISGauges (0, 0, GLOBAL (CrewCost) - - (crew_bought == CREW_EXPENSE_THRESHOLD ? 2 : 0)); - crew_delta = -1; - --StarShipPtr->ShipInfo.crew_level; - + if (StarShipPtr->ShipInfo.crew_level > 0) + { + if (StarShipPtr->ShipInfo.crew_level > 1) + DeltaSISGauges (0, 0, GLOBAL (CrewCost) + - (crew_bought == + CREW_EXPENSE_THRESHOLD ? 2 : 0)); + else + DeltaSISGauges (UNDEFINED_DELTA,UNDEFINED_DELTA, + (COUNT)ShipCost[GET_RACE_ID (StarShipPtr)]); + crew_delta = -1; + --StarShipPtr->ShipInfo.crew_level; + } ShowShipCrew (StarShipPtr, &pMS->flash_rect0); r.corner.x = pMS->flash_rect0.corner.x; r.corner.y = pMS->flash_rect0.corner.y @@ -941,53 +972,6 @@ DoModifyShips (PMENU_STATE pMS) SetContext (SpaceContext); SetFlashRect (&r, (FRAME)0); } - else - { - COUNT ResUnits; - - ResUnits = (COUNT)ShipCost[ - GET_RACE_ID (StarShipPtr) - ]; - crew_delta = -(StarShipPtr->ShipInfo.crew_level - 1); - crew_bought = (SIZE)MAKE_WORD ( - GET_GAME_STATE (CREW_PURCHASED0), - GET_GAME_STATE (CREW_PURCHASED1) - ) - CREW_EXPENSE_THRESHOLD; - if (crew_bought <= 0 || (crew_bought += crew_delta) >= 0) - crew_bought = -crew_delta; - else - { - ResUnits += -crew_bought - * (GLOBAL (CrewCost) - 2); - crew_bought -= crew_delta; - } - ResUnits += crew_bought * GLOBAL (CrewCost); - - SetFlashRect (NULL_PTR, (FRAME)0); - ClearSemaphore (GraphicsSem); - ShowCombatShip ((COUNT)pMS->CurState, StarShipPtr); - SetSemaphore (GraphicsSem); - pMS->flash_rect0.extent.width = SHIP_WIN_WIDTH; - SetFlashRect (&pMS->flash_rect0, (FRAME)0); - - UnlockStarShip ( - &GLOBAL (built_ship_q), hStarShip - ); - - RemoveQueue ( - &GLOBAL (built_ship_q), hStarShip - ); - FreeStarShip ( - &GLOBAL (built_ship_q), hStarShip - ); - - DeltaSISGauges ( - UNDEFINED_DELTA, UNDEFINED_DELTA, ResUnits - ); - hStarShip = 0; - - pMS->delta_item ^= MODIFY_CREW_FLAG; - } } if (hStarShip) @@ -995,8 +979,10 @@ DoModifyShips (PMENU_STATE pMS) UnlockStarShip ( &GLOBAL (built_ship_q), hStarShip ); + if ((pMS->delta_item != MODIFY_CREW_FLAG) + && (pMS->delta_item != 0)) + pMS->delta_item = MODIFY_CREW_FLAG; } - CrewTransaction (crew_delta); } }