From b8d5ce19883d3898de600417dde23bdb34362a15 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Thu, 19 Jun 2003 05:28:45 +0000 Subject: [PATCH] DoInput now selectively clears the input state. Addresses bugs #378 and #379. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@983 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 ++ sc2/src/sc2code/comm.c | 2 +- sc2/src/sc2code/encount.c | 2 +- sc2/src/sc2code/gameinp.c | 7 +++++-- sc2/src/sc2code/gameopt.c | 6 +++--- sc2/src/sc2code/hyper.c | 2 +- sc2/src/sc2code/melee.c | 2 +- sc2/src/sc2code/pickship.c | 2 +- sc2/src/sc2code/planets/cargo.c | 2 +- sc2/src/sc2code/planets/devices.c | 2 +- sc2/src/sc2code/planets/lander.c | 2 +- sc2/src/sc2code/planets/pstarmap.c | 2 +- sc2/src/sc2code/planets/roster.c | 2 +- sc2/src/sc2code/planets/scan.c | 2 +- sc2/src/sc2code/planets/solarsys.c | 2 +- sc2/src/sc2code/restart.c | 2 +- sc2/src/sc2code/starbase.c | 4 ++-- sc2/src/sc2code/starcon.h | 2 +- 18 files changed, 26 insertions(+), 21 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index c7e85b005..291155b0b 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.3: +- Fixed some "false key cancels" in the input system, addressing bugs + #378 and #379 -Michael - Completely reworked the input system - Added PC version outtakes, from chmmravatar - Fix crash in PlayStream when whole file is prebuffered and its not diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index b766766a1..f7c9f25ae 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -2049,7 +2049,7 @@ HailAlien (void) LastActivity |= CHECK_LOAD; /* prevent spurious input */ (*CommData.init_encounter_func) (); - DoInput ((PVOID)&ES); + DoInput ((PVOID)&ES, TRUE); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) (*CommData.uninit_encounter_func) (); diff --git a/sc2/src/sc2code/encount.c b/sc2/src/sc2code/encount.c index 41745b4c0..3b005f67d 100644 --- a/sc2/src/sc2code/encount.c +++ b/sc2/src/sc2code/encount.c @@ -312,7 +312,7 @@ InitEncounter (void) SetFlashRect ((PRECT)~0L, (FRAME)0); ClearSemaphore (GraphicsSem); - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, TRUE); SetSemaphore (GraphicsSem); SetFlashRect (NULL_PTR, (FRAME)0); diff --git a/sc2/src/sc2code/gameinp.c b/sc2/src/sc2code/gameinp.c index c38e366dd..259248853 100644 --- a/sc2/src/sc2code/gameinp.c +++ b/sc2/src/sc2code/gameinp.c @@ -54,7 +54,6 @@ static void _clear_menu_state (void) { DWORD initTime = GetTimeCounter (); - TFB_ResetControls (); CurrentMenuState.up = 0; CurrentMenuState.down = 0; CurrentMenuState.left = 0; @@ -188,9 +187,13 @@ SetDefaultMenuRepeatDelay () } void -DoInput (PVOID pInputState) +DoInput (PVOID pInputState, BOOLEAN resetInput) { SetMenuRepeatDelay (ACCELERATION_INCREMENT, MENU_REPEAT_DELAY, ACCELERATION_INCREMENT); + if (resetInput) + { + TFB_ResetControls (); + } do { TaskSwitch (); diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index c0eeeb023..03c5e3a10 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -421,7 +421,7 @@ DoNaming (PMENU_STATE pMS) ClearSemaphore (GraphicsSem); EnableCharacterMode (); - DoInput (pMS); + DoInput (pMS, TRUE); DisableCharacterMode (); pMS->InputFunc = DoSettings; @@ -1162,7 +1162,7 @@ PickGame (PMENU_STATE pMS) pMS->CurString = (STRING)&desc_array[0]; ClearSemaphore (GraphicsSem); - DoInput (pMS); + DoInput (pMS, TRUE); SetSemaphore (GraphicsSem); pMS->Initialized = -1; @@ -1279,7 +1279,7 @@ GameOptions (void) MenuState.InputFunc = DoGameOptions; MenuState.CurState = SAVE_GAME; - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, TRUE); pLocMenuState = 0; diff --git a/sc2/src/sc2code/hyper.c b/sc2/src/sc2code/hyper.c index efb7d6e98..e6f0d1b62 100644 --- a/sc2/src/sc2code/hyper.c +++ b/sc2/src/sc2code/hyper.c @@ -1594,7 +1594,7 @@ UnbatchGraphics (); SetFlashRect ((PRECT)~0L, (FRAME)0); ClearSemaphore (GraphicsSem); - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, TRUE); SetSemaphore (GraphicsSem); SetFlashRect (NULL_PTR, (FRAME)0); diff --git a/sc2/src/sc2code/melee.c b/sc2/src/sc2code/melee.c index 2b885ace1..fd2df85ac 100644 --- a/sc2/src/sc2code/melee.c +++ b/sc2/src/sc2code/melee.c @@ -1893,7 +1893,7 @@ Melee (void) MenuState.side = 0; MenuState.star_bucks[0] = GetTeamValue (&MenuState.TeamImage[0]); MenuState.star_bucks[1] = GetTeamValue (&MenuState.TeamImage[1]); - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, TRUE); WaitForSoundEnd (TFBSOUND_WAIT_ALL); diff --git a/sc2/src/sc2code/pickship.c b/sc2/src/sc2code/pickship.c index 8e0a48656..ecc009baa 100644 --- a/sc2/src/sc2code/pickship.c +++ b/sc2/src/sc2code/pickship.c @@ -249,7 +249,7 @@ OldContext = SetContext (SpaceContext); ClearSemaphore (GraphicsSem); pMenuState = &MenuState; - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, TRUE); pMenuState = 0; SetSemaphore (GraphicsSem); diff --git a/sc2/src/sc2code/planets/cargo.c b/sc2/src/sc2code/planets/cargo.c index 597ea17bc..b67c55bf8 100644 --- a/sc2/src/sc2code/planets/cargo.c +++ b/sc2/src/sc2code/planets/cargo.c @@ -358,7 +358,7 @@ Cargo (PMENU_STATE pMS) DrawStatusMessage ((UNICODE *)~0); ClearSemaphore (GraphicsSem); - DoInput ((PVOID)pMS); + DoInput ((PVOID)pMS, TRUE); pMS->InputFunc = DoFlagshipCommands; pMS->CurState = CARGO + 1; diff --git a/sc2/src/sc2code/planets/devices.c b/sc2/src/sc2code/planets/devices.c index 66c993c10..b42522921 100644 --- a/sc2/src/sc2code/planets/devices.c +++ b/sc2/src/sc2code/planets/devices.c @@ -625,7 +625,7 @@ Devices (PMENU_STATE pMS) pMS->CurFrame = (FRAME)DeviceMap; TFB_ResetControls (); DoManipulateDevices (pMS); /* to make sure it's initialized */ - DoInput ((PVOID)pMS); + DoInput ((PVOID)pMS, TRUE); pMS->CurFrame = 0; pMS->InputFunc = DoFlagshipCommands; diff --git a/sc2/src/sc2code/planets/lander.c b/sc2/src/sc2code/planets/lander.c index 1d9b671c7..0b72bba07 100644 --- a/sc2/src/sc2code/planets/lander.c +++ b/sc2/src/sc2code/planets/lander.c @@ -1968,7 +1968,7 @@ PlanetSide (PMENU_STATE pMS) pMS->Initialized = FALSE; pMS->InputFunc = DoPlanetSide; - DoInput ((PVOID)pMS); + DoInput ((PVOID)pMS, FALSE); if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) { diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index 41503bd4b..531e21b5a 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -1126,7 +1126,7 @@ DoStarMap (void) OldMenuSounds = MenuSounds; MenuSounds = 0; - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, FALSE); MenuSounds = OldMenuSounds; pMenuState = 0; diff --git a/sc2/src/sc2code/planets/roster.c b/sc2/src/sc2code/planets/roster.c index 4ac7d180e..b3b0c5fea 100644 --- a/sc2/src/sc2code/planets/roster.c +++ b/sc2/src/sc2code/planets/roster.c @@ -436,7 +436,7 @@ Roster (void) MenuState.flash_frame0 = (FRAME)ship_pos; MenuState.flash_frame1 = (FRAME)modified_ship_pos; - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, TRUE); pMenuState = pOldMenuState; diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 06f87d2a7..ab8b26c24 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -1233,7 +1233,7 @@ ScanSystem (void) PrintCoarseScan3DO (); pMenuState = &MenuState; - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, FALSE); pMenuState = 0; if (ScanContext) diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index 79ab89d67..657a4a653 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -1917,7 +1917,7 @@ ExploreSolarSys (void) SolarSysState.GenFunc = GenerateIP (CurStarDescPtr->Index); InitSolarSys (); - DoInput ((PVOID)&SolarSysState.MenuState); + DoInput ((PVOID)&SolarSysState.MenuState, TRUE); UninitSolarSys (); pSolarSysState = 0; } diff --git a/sc2/src/sc2code/restart.c b/sc2/src/sc2code/restart.c index 214b7b58b..e215e46ab 100644 --- a/sc2/src/sc2code/restart.c +++ b/sc2/src/sc2code/restart.c @@ -244,7 +244,7 @@ LastActivity = WON_LAST_BATTLE; UnbatchGraphics (); FlushInput (); - DoInput ((PVOID)&MenuState); + DoInput ((PVOID)&MenuState, TRUE); SetSemaphore (GraphicsSem); SetFlashRect ((PRECT)0, (FRAME)0); diff --git a/sc2/src/sc2code/starbase.c b/sc2/src/sc2code/starbase.c index 7edb528b9..644717c05 100644 --- a/sc2/src/sc2code/starbase.c +++ b/sc2/src/sc2code/starbase.c @@ -384,7 +384,7 @@ ExitStarBase: break; } - DoInput ((PVOID)pMS); + DoInput ((PVOID)pMS, TRUE); pMS->Initialized = FALSE; pMS->CurState = OldState; @@ -497,7 +497,7 @@ TimePassage: } OldContext = SetContext (ScreenContext); - DoInput ((PVOID)pMenuState); + DoInput ((PVOID)pMenuState, TRUE); SetContext (OldContext); pMenuState = 0; diff --git a/sc2/src/sc2code/starcon.h b/sc2/src/sc2code/starcon.h index 90ef19b57..f2bff5d3c 100644 --- a/sc2/src/sc2code/starcon.h +++ b/sc2/src/sc2code/starcon.h @@ -185,7 +185,7 @@ extern BOOLEAN ConfirmExit (void); extern DWORD SeedRandomNumbers (void); extern BOOLEAN StarConDiskError (PSTR pFileName); extern void ReportDiskError (PSTR pFileName, DISK_ERROR ErrorCondition); -extern void DoInput (PVOID pInputState); +extern void DoInput (PVOID pInputState, BOOLEAN resetInput); extern BOOLEAN Battle (void); extern void EncounterBattle (void); extern void SetPlayerInput (void);