diff --git a/sc2/src/sc2code/planets/cargo.c b/sc2/src/sc2code/planets/cargo.c index d7c280980..18caa50cc 100644 --- a/sc2/src/sc2code/planets/cargo.c +++ b/sc2/src/sc2code/planets/cargo.c @@ -316,6 +316,10 @@ DoDiscardCargo (PMENU_STATE pMS) ShowRemainingCapacity (); UnlockMutex (GraphicsLock); } + else + { // no element left in cargo hold + PlayMenuSound (MENU_SOUND_FAILURE); + } } else { diff --git a/sc2/src/sc2code/planets/devices.c b/sc2/src/sc2code/planets/devices.c index 53ea0c591..346d956fc 100644 --- a/sc2/src/sc2code/planets/devices.c +++ b/sc2/src/sc2code/planets/devices.c @@ -211,8 +211,7 @@ DeviceFailed (BYTE which_device) { BYTE fade_buf[1]; - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 3), - 0, NotPositional (), NULL, GAME_SOUND_PRIORITY); + PlayMenuSound (MENU_SOUND_INVOKED); fade_buf[0] = FadeAllToWhite; SleepThreadUntil (XFormColorMap ((COLORMAPPTR)fade_buf, ONE_SECOND * 1) + (ONE_SECOND * 2)); @@ -458,11 +457,9 @@ DoManipulateDevices (PMENU_STATE pMS) ); NewState = LOBYTE (status); if (NewState) - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 2), - 0, NotPositional (), NULL, GAME_SOUND_PRIORITY); + PlayMenuSound (MENU_SOUND_FAILURE); else if (HIBYTE (status) == 0) - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 3), - 0, NotPositional (), NULL, GAME_SOUND_PRIORITY); + PlayMenuSound (MENU_SOUND_INVOKED); UnlockMutex (GraphicsLock); return ((BOOLEAN)NewState); diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index 1f3c5986c..f5845f336 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -1140,8 +1140,7 @@ OnStarNameFrame (PTEXTENTRY_STATE pTES) if (pSS->CurIndex < 0) { // nothing found if (PulsedInputState.key[KEY_MENU_NEXT]) - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 2), - 0, NotPositional (), NULL, 0); + PlayMenuSound (MENU_SOUND_FAILURE); return TRUE; } @@ -1242,8 +1241,7 @@ DoMoveCursor (PMENU_STATE pMS) #ifdef DEBUG if (instantMove) { - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 3), 0, - NotPositional (), NULL, GAME_SOUND_PRIORITY); + PlayMenuSound (MENU_SOUND_INVOKED); if (pMS->flash_task) { ConcludeTask (pMS->flash_task); @@ -1290,8 +1288,7 @@ DoMoveCursor (PMENU_STATE pMS) } else { // no search in QuasiSpace - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 2), - 0, NotPositional (), NULL, 0); + PlayMenuSound (MENU_SOUND_FAILURE); } } else diff --git a/sc2/src/sc2code/planets/roster.c b/sc2/src/sc2code/planets/roster.c index ec97fe3a6..aa94eb086 100644 --- a/sc2/src/sc2code/planets/roster.c +++ b/sc2/src/sc2code/planets/roster.c @@ -96,9 +96,10 @@ MatchSupportShip (PMENU_STATE pMS) return 0; } -static void +static BOOLEAN DeltaSupportCrew (SIZE crew_delta) { + BOOLEAN ret = FALSE; UNICODE buf[40]; HSTARSHIP hTemplate; SHIP_FRAGMENTPTR StarShipPtr, TemplatePtr; @@ -141,10 +142,13 @@ DeltaSupportCrew (SIZE crew_delta) SetContext (StatusContext); SetFlashRect (&r, (FRAME)0); } + ret = TRUE; } UnlockStarShip (&GLOBAL (avail_race_q), hTemplate); UnlockStarShip (&GLOBAL (built_ship_q), (HSTARSHIP)pMenuState->CurFrame); + + return ret; } #define SHIP_TOGGLE ((BYTE)(1 << 7)) @@ -260,26 +264,35 @@ DoModifyRoster (PMENU_STATE pMS) } else if (pMS->CurState & SHIP_TOGGLE) { + SIZE delta = 0; + BOOLEAN failed = FALSE; + if (up) { sy = -1; if (GLOBAL_SIS (CrewEnlisted)) - { - LockMutex (GraphicsLock); - DeltaSupportCrew (1); - UnlockMutex (GraphicsLock); - } + delta = 1; + else + failed = TRUE; } else if (down) { sy = 1; - if (GLOBAL_SIS (CrewEnlisted) - < GetCPodCapacity (NULL_PTR)) - { - LockMutex (GraphicsLock); - DeltaSupportCrew (-1); - UnlockMutex (GraphicsLock); - } + if (GLOBAL_SIS (CrewEnlisted) < GetCPodCapacity (NULL_PTR)) + delta = -1; + else + failed = TRUE; + } + + if (delta != 0) + { + LockMutex (GraphicsLock); + failed = !DeltaSupportCrew (delta); + UnlockMutex (GraphicsLock); + } + if (failed) + { // not enough room or crew + PlayMenuSound (MENU_SOUND_FAILURE); } } else diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index d38317581..cbc229e98 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -990,8 +990,7 @@ DoScan (PMENU_STATE pMS) || (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == GAS_GIANT_ATMOSPHERE)) { // cannot dispatch to shielded planets or gas giants - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 2), - 0, NotPositional (), NULL, GAME_SOUND_PRIORITY); + PlayMenuSound (MENU_SOUND_FAILURE); return (TRUE); } @@ -1005,8 +1004,7 @@ DoScan (PMENU_STATE pMS) || GLOBAL_SIS (NumLanders) == 0 || GLOBAL_SIS (CrewEnlisted) == 0) { - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 2), - 0, NotPositional (), NULL, GAME_SOUND_PRIORITY); + PlayMenuSound (MENU_SOUND_FAILURE); return (TRUE); } @@ -1034,8 +1032,7 @@ DoScan (PMENU_STATE pMS) // Various scans if (pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) { // cannot scan shielded planets - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 2), - 0, NotPositional (), NULL, GAME_SOUND_PRIORITY); + PlayMenuSound (MENU_SOUND_FAILURE); return (TRUE); }