From: <av...@us...> - 2009-12-05 22:15:31
|
Revision: 3393 http://sc2.svn.sourceforge.net/sc2/?rev=3393&view=rev Author: avolkov Date: 2009-12-05 22:15:23 +0000 (Sat, 05 Dec 2009) Log Message: ----------- Planet rotation task retired; this introduces a DoInput frame callback and lays the foundation for the removal of credits task Modified Paths: -------------- trunk/sc2/src/uqm/confirm.c trunk/sc2/src/uqm/controls.h trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/planets/generate.h trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/pl_stuff.c trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/plangen.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/restart.c trunk/sc2/src/uqm/util.c Modified: trunk/sc2/src/uqm/confirm.c =================================================================== --- trunk/sc2/src/uqm/confirm.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/confirm.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -108,13 +108,7 @@ SetSystemRect (&r); DrawConfirmationWindow (response); - - // Releasing the lock lets the rotate_planet_task - // draw a frame. PauseRotate can still allow one more frame - // to be drawn, so it is safer to just not release the lock - //UnlockMutex (GraphicsLock); FlushGraphics (); - //LockMutex (GraphicsLock); FlushInput (); done = FALSE; @@ -188,7 +182,8 @@ (void)self; SleepThread (ONE_SECOND / 20); return !(PulsedInputState.menu[KEY_MENU_SELECT] || - PulsedInputState.menu[KEY_MENU_CANCEL]); + PulsedInputState.menu[KEY_MENU_CANCEL] || + (GLOBAL (CurrentActivity) & CHECK_ABORT)); } void @@ -205,7 +200,7 @@ RECT windowRect; POPUP_STATE state; MENU_SOUND_FLAGS s0, s1; - + InputFrameCallback *oldCallback; if (!bank) { @@ -247,10 +242,12 @@ GetMenuSounds (&s0, &s1); SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); + oldCallback = SetInputCallback (NULL); state.InputFunc = DoPopup; DoInput (&state, TRUE); + SetInputCallback (oldCallback); ClearSystemRect (); DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); Modified: trunk/sc2/src/uqm/controls.h =================================================================== --- trunk/sc2/src/uqm/controls.h 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/controls.h 2009-12-05 22:15:23 UTC (rev 3393) @@ -113,6 +113,13 @@ BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput); void DoPopupWindow(const char *msg); + +typedef void (InputFrameCallback) (void); +// Anything using input callbacks MUST NOT keep GraphicsLock across +// InputFunc executions. This also means NOT holding GraphicsLock +// when calling DoInput(). +InputFrameCallback* SetInputCallback (InputFrameCallback *); +// pInputState must point to a struct derived from INPUT_STATE_DESC void DoInput (void *pInputState, BOOLEAN resetInput); extern volatile BOOLEAN GamePaused; Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/gameinp.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -68,6 +68,8 @@ volatile BOOLEAN ExitRequested; volatile BOOLEAN GamePaused; +static InputFrameCallback *inputCallback; + static void _clear_menu_state (void) { @@ -275,7 +277,19 @@ ExitRequested = TRUE; } +InputFrameCallback * +SetInputCallback (InputFrameCallback *callback) +{ + InputFrameCallback *old = inputCallback; + + // Replacing an existing callback with another is not a problem, + // but currently this should never happen, which is why the assert. + assert (!old || !callback); + inputCallback = callback; + return old; +} + void SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step, BOOLEAN gestalt) { @@ -384,6 +398,10 @@ PlaySoundEffect (S, 0, NotPositional (), NULL, 0); } + + if (inputCallback) + inputCallback (); + } while (((INPUT_STATE_DESC*)pInputState)->InputFunc (pInputState)); if (resetInput) Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/gameopt.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -1099,14 +1099,12 @@ RECT DlgRect; STAMP DlgStamp; TimeCount TimeOut; + InputFrameCallback *oldCallback; TimeOut = FadeMusic (0, ONE_SECOND / 2); - if (pSolarSysState) - { - pSolarSysState->PauseRotate = 1; - TaskSwitch (); - } + // Deactivate any background drawing, like planet rotation + oldCallback = SetInputCallback (NULL); LoadGameDescriptions (desc_array); @@ -1128,6 +1126,7 @@ FadeMusic (NORMAL_VOLUME, 0); DoInput (pMS, TRUE); + LockMutex (GraphicsLock); pMS->Initialized = FALSE; pMS->InputFunc = DoGameOptions; @@ -1148,9 +1147,6 @@ DrawStamp (&DlgStamp); ScreenTransition (3, &DlgRect); UnbatchGraphics (); - - if (pSolarSysState) - pSolarSysState->PauseRotate = 0; } DestroyDrawable (ReleaseDrawable (DlgStamp.frame)); @@ -1158,6 +1154,9 @@ SetContext (OldContext); UnlockMutex (GraphicsLock); + // Reactivate any background drawing, like planet rotation + SetInputCallback (oldCallback); + return (retval); } Modified: trunk/sc2/src/uqm/planets/generate.h =================================================================== --- trunk/sc2/src/uqm/planets/generate.h 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/generate.h 2009-12-05 22:15:23 UTC (rev 3393) @@ -28,6 +28,8 @@ * - split off pickupMineral, pickupEnergy, pickupLife from Generate* * - split off generateOrbital in a calculation and an activation * (graphics and music) part. + * - make generateOrbital return a meaningful value, specifically, whether + * or not the player is going into orbit * - for GenerateNameFunction, set the name in an argument, instead * of in GLOBAL_SYS(PlanetName) * - make generateName work for moons Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/lander.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -1312,52 +1312,78 @@ } static void +animationInterframe (TimeCount *TimeIn, COUNT periods) +{ +#define ANIM_FRAME_RATE (ONE_SECOND / 30) + + for ( ; periods; --periods) + { + LockMutex (GraphicsLock); + RotatePlanetSphere (TRUE); + UnlockMutex (GraphicsLock); + + SleepThreadUntil (*TimeIn + ANIM_FRAME_RATE); + *TimeIn = GetTimeCounter (); + } +} + +static void AnimateLaunch (FRAME farray) { RECT r; STAMP s; COUNT num_frames; - DWORD Time; + TimeCount NextTime; - Time = GetTimeCounter (); + LockMutex (GraphicsLock); + SetContext (SpaceContext); - s.origin.x = s.origin.y = 0; - s.frame = DecFrameIndex (farray); + r.corner.x = 0; + r.corner.y = 0; + r.extent.width = 0; + s.origin.x = 0; + s.origin.y = 0; + s.frame = farray; - num_frames = GetFrameCount (s.frame); - do + for (num_frames = GetFrameCount (s.frame); num_frames; --num_frames) { - GetFrameRect (s.frame, &r); - s.frame = IncFrameIndex (s.frame); + NextTime = GetTimeCounter () + (ONE_SECOND / 22); + + BatchGraphics (); RepairBackRect (&r); +#ifdef SPIN_ON_LAUNCH + RotatePlanetSphere (FALSE); +#else + DrawDefaultPlanetSphere (); +#endif DrawStamp (&s); - + UnbatchGraphics (); UnlockMutex (GraphicsLock); - SleepThreadUntil (Time + (ONE_SECOND / 22)); - Time = GetTimeCounter (); + GetFrameRect (s.frame, &r); + s.frame = IncFrameIndex (s.frame); + SleepThreadUntil (NextTime); + LockMutex (GraphicsLock); - } while (--num_frames); + } - GetFrameRect (s.frame, &r); RepairBackRect (&r); + UnlockMutex (GraphicsLock); } static void -InitPlanetSide (POINT pt) +AnimateLanderWarmup (void) { SIZE num_crew; STAMP s; CONTEXT OldContext; - DWORD Time; + TimeCount TimeIn = GetTimeCounter (); LockMutex (GraphicsLock); OldContext = SetContext (RadarContext); UnlockMutex (GraphicsLock); - Time = GetTimeCounter (); - s.origin.x = 0; s.origin.y = 0; s.frame = SetAbsFrameIndex (LanderFrame[0], @@ -1367,22 +1393,20 @@ DrawStamp (&s); UnlockMutex (GraphicsLock); - SleepThread (ONE_SECOND / 15); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); for (num_crew = 0; num_crew < (NUM_CREW_COLS * NUM_CREW_ROWS) && GLOBAL_SIS (CrewEnlisted); ++num_crew) { - SleepThreadUntil (Time + ONE_SECOND / 30); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 1); + LockMutex (GraphicsLock); DeltaSISGauges (-1, 0, 0); DeltaLanderCrew (1, 0); UnlockMutex (GraphicsLock); } - SleepThreadUntil (Time + (ONE_SECOND / 15)); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); if (GET_GAME_STATE (IMPROVED_LANDER_SHOT)) s.frame = SetAbsFrameIndex (s.frame, 58); @@ -1393,8 +1417,7 @@ DrawStamp (&s); UnlockMutex (GraphicsLock); - SleepThreadUntil (Time + (ONE_SECOND / 15)); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); if (GET_GAME_STATE (IMPROVED_LANDER_SPEED)) s.frame = SetAbsFrameIndex (s.frame, 57); @@ -1406,8 +1429,7 @@ DrawStamp (&s); UnlockMutex (GraphicsLock); - SleepThreadUntil (Time + (ONE_SECOND / 15)); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); s.frame = IncFrameIndex (s.frame); } @@ -1417,31 +1439,23 @@ if (GET_GAME_STATE (IMPROVED_LANDER_CARGO)) { - SleepThreadUntil (Time + (ONE_SECOND / 15)); - Time = GetTimeCounter (); + animationInterframe (&TimeIn, 2); s.frame = SetAbsFrameIndex (s.frame, 59); LockMutex (GraphicsLock); DrawStamp (&s); UnlockMutex (GraphicsLock); } -#ifndef SPIN_ON_LAUNCH - pSolarSysState->PauseRotate = 1; -#endif - SleepThreadUntil (Time + (ONE_SECOND / 15)); - LockMutex (GraphicsLock); + animationInterframe (&TimeIn, 2); + PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_DEPARTS), NotPositional (), NULL, GAME_SOUND_PRIORITY + 1); - SetContext (SpaceContext); - AnimateLaunch (LanderFrame[5]); -#ifdef SPIN_ON_LAUNCH - pSolarSysState->PauseRotate = 1; - UnlockMutex (GraphicsLock); - TaskSwitch (); - LockMutex (GraphicsLock); -#endif +} +static void +InitPlanetSide (POINT pt) +{ // Adjust landing location by a random jitter. #define RANDOM_MISS 64 // Jitter the X landing point. @@ -1460,6 +1474,7 @@ curLanderLoc = pt; + LockMutex (GraphicsLock); SetContext (SpaceContext); SetContextFont (TinyFont); @@ -1495,12 +1510,8 @@ ScreenTransition (3, &r); UnbatchGraphics (); - - LoadIntoExtraScreen (&r); } - SetContext (OldContext); - UnlockMutex (GraphicsLock); SET_GAME_STATE (PLANETARY_LANDING, 1); @@ -1810,7 +1821,6 @@ ScreenTransition (3, pRect); UnbatchGraphics (); - LoadIntoExtraScreen (pRect); SetContext (OldContext); UnlockMutex (GraphicsLock); } @@ -1960,8 +1970,9 @@ crew_left = 0; damage_index = 0; explosion_index = 0; - pSolarSysState->MenuState.Initialized += 4; + AnimateLanderWarmup (); + AnimateLaunch (LanderFrame[5]); InitPlanetSide (planetLoc); landerInputState.NextTime = GetTimeCounter () + PLANET_SIDE_RATE; @@ -1999,18 +2010,9 @@ LandingTakeoffSequence (&landerInputState, FALSE); ReturnToOrbit (&r); -#ifdef SPIN_ON_LAUNCH - // If PauseRotate is set to 2 the plaet will be displayed, but won't rotate - // Until the lander animation is complete - pSolarSysState->PauseRotate = 0; - // Give The RotatePlanet thread a slice to draw the planet - SleepThread (1); -#endif - - LockMutex (GraphicsLock); - SetContext (SpaceContext); - AnimateLaunch (LanderFrame[6]); + + LockMutex (GraphicsLock); DeltaSISGauges (crew_left, 0, 0); if (PSD.ElementLevel) @@ -2024,7 +2026,6 @@ } DrawStorageBays (FALSE); } - UnlockMutex (GraphicsLock); GLOBAL_SIS (TotalBioMass) += PSD.BiologicalLevel; @@ -2058,9 +2059,6 @@ ZeroVelocityComponents (&GLOBAL (velocity)); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); - - pSolarSysState->MenuState.Initialized -= 4; - pSolarSysState->PauseRotate = 0; } void Modified: trunk/sc2/src/uqm/planets/pl_stuff.c =================================================================== --- trunk/sc2/src/uqm/planets/pl_stuff.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/pl_stuff.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -69,7 +69,16 @@ UnbatchGraphics (); } +void +DrawDefaultPlanetSphere (void) +{ + CONTEXT oldContext; + oldContext = SetContext (SpaceContext); + DrawPlanetSphere (SIS_SCREEN_WIDTH / 2, PLANET_ORG_Y); + SetContext (oldContext); +} + void InitSphereRotation (int direction, BOOLEAN shielded) { @@ -218,6 +227,21 @@ } } +void +RotatePlanetSphere (BOOLEAN keepRate) +{ + static TimeCount NextTime; + TimeCount Now = GetTimeCounter (); + + if (keepRate && Now < NextTime) + return; // not time yet + + NextTime = Now + PLANET_ROTATION_RATE; + DrawDefaultPlanetSphere (); + + PrepareNextRotationFrame (); +} + // rgb.a is ignored void DrawPlanet (int x, int y, int dy, Color rgb) Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/planets.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -35,9 +35,6 @@ #include "libs/graphics/gfx_common.h" -extern int rotate_planet_task (void *data); - - void DrawScannedObjects (BOOLEAN Reversed) { @@ -170,8 +167,13 @@ DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); } - else + else if (Mode == DRAW_ORBITAL_FULL) { + DrawDefaultPlanetSphere (); + } + + if (Mode != DRAW_ORBITAL_WAIT) + { DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, BLACK_COLOR); } @@ -185,6 +187,7 @@ if (Mode != DRAW_ORBITAL_WAIT) { + // for later RepairBackRect() LoadIntoExtraScreen (&r); } } @@ -207,7 +210,7 @@ #endif WaitMode = !(LastActivity & CHECK_LOAD) && - (pSolarSysState->MenuState.Initialized <= 2); + (pSolarSysState->MenuState.Initialized != 3); if (WaitMode) { @@ -216,9 +219,11 @@ UnlockMutex (GraphicsLock); } - if (pSolarSysState->MenuState.flash_task == 0) + // TODO: split off the scan screen redraw code into a separate + // function so that we could lose this hack. + if (!pSolarSysState->TopoFrame) { - // The "rotate planets" task is not initialised yet. + // TopoFrame has not been initialised yet. // This means the call to LoadPlanet is made from some // GenerateFunctions.generateOribital() function. PLANET_DESC *pPlanetDesc; @@ -231,10 +236,6 @@ GeneratePlanetSurface (pPlanetDesc, SurfDefFrame); SetPlanetMusic (pPlanetDesc->data_index & ~PLANET_SHIELDED); - - if (pPlanetDesc->pPrevDesc != &pSolarSysState->SunDesc[0]) - pPlanetDesc = pPlanetDesc->pPrevDesc; - GeneratePlanetSide (); } @@ -245,20 +246,14 @@ if (!PLRPlaying ((MUSIC_REF)~0)) PlayMusic (LanderMusic, TRUE, 1); - if (pSolarSysState->MenuState.flash_task == 0) + if (WaitMode) { assert (pSolarSysState->MenuState.Initialized == 2); - // Only zoom when not already in orbit - if (!(LastActivity & CHECK_LOAD)) - ZoomInPlanetSphere (); + ZoomInPlanetSphere (); // XXX: Mark as in-orbit. This should go away eventually pSolarSysState->MenuState.Initialized = 3; - - pSolarSysState->MenuState.flash_task = - AssignTask (rotate_planet_task, 4096, - "rotate planets"); } } @@ -268,13 +263,6 @@ COUNT i; PLANET_ORBIT *Orbit = &pSolarSysState->Orbit; - if (pSolarSysState->MenuState.flash_task) - { - ConcludeTask (pSolarSysState->MenuState.flash_task); -// Task_SetState (pSolarSysState->MenuState.flash_task, TASK_EXIT); - pSolarSysState->MenuState.flash_task = 0; - } - UninitSphereRotation (); StopMusic (); @@ -331,7 +319,6 @@ )); pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0; FreeLanderFont (&pSolarSysState->SysInfo.PlanetInfo); - pSolarSysState->PauseRotate = 0; UnlockMutex (GraphicsLock); } @@ -402,24 +389,25 @@ case STARMAP: { BOOLEAN AutoPilotSet; + InputFrameCallback *oldCallback; + // Deactivate planet rotation + oldCallback = SetInputCallback (NULL); + LockMutex (GraphicsLock); - pSolarSysState->PauseRotate = 1; RepairSISBorder (); UnlockMutex (GraphicsLock); - TaskSwitch (); AutoPilotSet = StarMap (); - if (GLOBAL (CurrentActivity) & CHECK_ABORT) return FALSE; + // Reactivate planet rotation + SetInputCallback (oldCallback); + if (!AutoPilotSet) { // Redraw the orbital display LoadPlanet (NULL); - LockMutex (GraphicsLock); - pSolarSysState->PauseRotate = 0; - UnlockMutex (GraphicsLock); break; } // Fall through !!! @@ -444,10 +432,19 @@ return TRUE; } +static void +on_input_frame (void) +{ + LockMutex (GraphicsLock); + RotatePlanetSphere (TRUE); + UnlockMutex (GraphicsLock); +} + void PlanetOrbitMenu (void) { void *oldInputFunc = pSolarSysState->MenuState.InputFunc; + InputFrameCallback *oldCallback; DrawMenuStateStrings (PM_SCAN, SCAN); LockMutex (GraphicsLock); @@ -456,12 +453,15 @@ pSolarSysState->MenuState.CurState = SCAN; SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + oldCallback = SetInputCallback (on_input_frame); // XXX: temporary; will have an own MENU_STATE pSolarSysState->MenuState.InputFunc = DoPlanetOrbit; DoInput (&pSolarSysState->MenuState, TRUE); pSolarSysState->MenuState.InputFunc = oldInputFunc; + SetInputCallback (oldCallback); + LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/planets.h 2009-12-05 22:15:23 UTC (rev 3393) @@ -226,7 +226,6 @@ * [5] = bio 3 (world-specific) */ Color Tint_rgb; - UBYTE PauseRotate; FRAME TopoFrame; PLANET_ORBIT Orbit; }; @@ -269,10 +268,12 @@ extern void UninitSphereRotation (void); extern void PrepareNextRotationFrame (void); extern void DrawPlanetSphere (int x, int y); +extern void DrawDefaultPlanetSphere (void); extern void RenderPlanetSphere (FRAME Frame, int offset, BOOLEAN doThrob); extern void SetShieldThrobEffect (FRAME FromFrame, int offset, FRAME ToFrame); extern void ZoomInPlanetSphere (void); +extern void RotatePlanetSphere (BOOLEAN keepRate); extern void DrawScannedObjects (BOOLEAN Reversed); extern void GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, Modified: trunk/sc2/src/uqm/planets/plangen.c =================================================================== --- trunk/sc2/src/uqm/planets/plangen.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/plangen.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -1958,54 +1958,3 @@ TFB_SeedRandom (old_seed); } -int -rotate_planet_task (void *data) -{ - Task task = (Task) data; - DWORD TimeIn; - SOLARSYS_STATE *pSS; - - pSS = pSolarSysState; - - TimeIn = GetTimeCounter (); - while (!Task_ReadState (task, TASK_EXIT)) - { - CONTEXT oldContext; - - { - // This lock was placed before the RotatePlanet call - // To prevent the thread from being interrupted by the flash - // task while computing the Planet Frame. This should help - // to smooth out the planet rotation animation. - // The PauseRotate needs to be placed after the lock, - // to guarantee that PauseRotate doesn't change while waiting - // to acquire the graphics lock - LockMutex (GraphicsLock); - - if (*(volatile UBYTE *)&pSS->PauseRotate != 1 - && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) - { - //PauseRotate == 2 is a single-step - if (*(volatile UBYTE *)&pSS->PauseRotate == 2) - pSS->PauseRotate = 1; - - oldContext = SetContext (SpaceContext); - DrawPlanetSphere (SIS_SCREEN_WIDTH / 2, PLANET_ORG_Y); - SetContext (oldContext); - - PrepareNextRotationFrame (); - } - - UnlockMutex (GraphicsLock); - - SleepThreadUntil (TimeIn + PLANET_ROTATION_RATE); - TimeIn = GetTimeCounter (); - } - } - - FinishTask (task); - - return 0; -} - - Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/scan.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -645,6 +645,7 @@ { DWORD TimeIn = GetTimeCounter (); BOOLEAN select, cancel; + select = PulsedInputState.menu[KEY_MENU_SELECT]; cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; @@ -689,6 +690,7 @@ } else { + InputFrameCallback *oldCallback; COUNT fuel_required; fuel_required = (COUNT)( @@ -698,6 +700,9 @@ EraseCoarseScan (); + // Deactivate planet rotation callback + oldCallback = SetInputCallback (NULL); + LockMutex (GraphicsLock); DeltaSISGauges (0, -(SIZE)fuel_required, 0); SetContext (ScanContext); @@ -743,6 +748,9 @@ PrintCoarseScanPC (); else PrintCoarseScan3DO (); + + // Reactivate planet rotation callback + SetInputCallback (oldCallback); } DrawMenuStateStrings (PM_MIN_SCAN, DISPATCH_SHUTTLE); @@ -1019,11 +1027,6 @@ return (TRUE); } - pSolarSysState->MenuState.Initialized += 4; -#ifndef SPIN_ON_SCAN - pSolarSysState->PauseRotate = 1; -#endif - min_scan = pMS->CurState; if (min_scan != AUTO_SCAN) max_scan = min_scan; @@ -1117,6 +1120,9 @@ DrawPlanet (0, 0, i, rgb); DrawScannedStuff (i, min_scan); UnbatchGraphics (); +#ifdef SPIN_ON_SCAN + RotatePlanetSphere (TRUE); +#endif UnlockMutex (GraphicsLock); } @@ -1157,8 +1163,6 @@ else UnlockMutex (GraphicsLock); - pSolarSysState->MenuState.Initialized -= 4; - pSolarSysState->PauseRotate = 0; FlushInput (); } else if (optWhichMenu == OPT_PC || Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -186,8 +186,10 @@ bool playerInPlanetOrbit (void) { + assert (!pSolarSysState || pSolarSysState->MenuState.Initialized < 4); + return playerInSolarSystem () && - pSolarSysState->MenuState.Initialized >= 3; + pSolarSysState->MenuState.Initialized == 3; // XXX: This test will change eventually } @@ -1275,8 +1277,9 @@ || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) return; - if (pSolarSysState->MenuState.flash_task) - { // We've entered orbit; LoadPlanet() set flash_task to rotate planet + // Implement a to-do in generate.h for a better test + if (pSolarSysState->TopoFrame) + { // We've entered orbit; LoadPlanet() called planet surface-gen code PlanetOrbitMenu (); FreePlanet (); } Modified: trunk/sc2/src/uqm/restart.c =================================================================== --- trunk/sc2/src/uqm/restart.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/restart.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -43,6 +43,10 @@ #include "libs/inplib.h" +// TODO: This entire module fails to uphold the GraphicsLock semantics +// This either has to be fixed, or GraphicsLock completely ignored, +// or will become irrelevant if GraphicsLock completely removed. + enum { START_NEW_GAME = 0, Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-12-05 17:04:20 UTC (rev 3392) +++ trunk/sc2/src/uqm/util.c 2009-12-05 22:15:23 UTC (rev 3393) @@ -172,9 +172,8 @@ SetSystemRect (&r); DrawStamp (&s); - // Releasing the lock lets the rotate_planet_task - // draw a frame. PauseRotate can still allow one more frame - // to be drawn, so it is safer to just not release the lock + // It is safer to just not release the lock so any graphics tasks + // would be blocked //UnlockMutex (GraphicsLock); FlushGraphics (); //LockMutex (GraphicsLock); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |