Rearranged the StartGame() code paths to make it cleaner and allow it to return FALSE on Quit (partially fixes #52); Intro now plays on New Game only, and Main menu times out into Credits
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2220 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -87,7 +87,8 @@ DoConfirmExit (void)
|
||||
static BOOLEAN in_confirm = FALSE;
|
||||
fprintf (stderr, "Confirming Exit!\n");
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
|
||||
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE)
|
||||
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE &&
|
||||
!(LastActivity & CHECK_RESTART))
|
||||
SuspendGameClock ();
|
||||
if (CommData.ConversationPhrases && PlayingTrack ())
|
||||
PauseTrack ();
|
||||
@@ -180,7 +181,8 @@ DoConfirmExit (void)
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
|
||||
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE)
|
||||
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE &&
|
||||
!(LastActivity & CHECK_RESTART))
|
||||
ResumeGameClock ();
|
||||
if (CommData.ConversationPhrases && PlayingTrack ())
|
||||
{
|
||||
|
||||
+18
-18
@@ -75,7 +75,7 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic)
|
||||
}
|
||||
|
||||
void
|
||||
Introduction (void)
|
||||
SplashScreen (void (* DoProcessing)(DWORD TimeOut))
|
||||
{
|
||||
BYTE xform_buf[1];
|
||||
STAMP s;
|
||||
@@ -95,16 +95,9 @@ Introduction (void)
|
||||
|
||||
xform_buf[0] = FadeAllToColor;
|
||||
TimeOut = XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2);
|
||||
LoadMasterShipList ();
|
||||
FlushInput ();
|
||||
InitGameKernel ();
|
||||
|
||||
while ((GetTimeCounter () <= TimeOut) &&
|
||||
!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||
{
|
||||
UpdateInputState ();
|
||||
TaskSwitch ();
|
||||
}
|
||||
if (DoProcessing)
|
||||
DoProcessing (TimeOut);
|
||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
{
|
||||
return;
|
||||
@@ -136,15 +129,22 @@ Introduction (void)
|
||||
* engine. -- Michael */
|
||||
xform_buf[0] = FadeAllToBlack;
|
||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2));
|
||||
}
|
||||
|
||||
if (InputState == 0)
|
||||
{ /* by default we do 3DO cinematics; or PC slides when 3DO files are
|
||||
* not present */
|
||||
if (optWhichIntro == OPT_PC ||
|
||||
!DoFMV ("slides/intro/intro.duk", NULL, TRUE))
|
||||
ShowPresentation ( CaptureStringTable (
|
||||
LoadStringTable (INTROPRES_STRTAB)));
|
||||
}
|
||||
void
|
||||
Introduction (void)
|
||||
{
|
||||
BYTE xform_buf[1];
|
||||
|
||||
/* by default we do 3DO cinematics; or PC slides when 3DO files are
|
||||
* not present */
|
||||
if (optWhichIntro == OPT_PC ||
|
||||
!DoFMV ("slides/intro/intro.duk", NULL, TRUE))
|
||||
ShowPresentation ( CaptureStringTable (
|
||||
LoadStringTable (INTROPRES_STRTAB)));
|
||||
|
||||
xform_buf[0] = FadeAllToBlack;
|
||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
|
||||
extern void Logo (void);
|
||||
extern void SplashScreen (void (* DoProcessing)(DWORD TimeOut));
|
||||
extern void Introduction (void);
|
||||
extern void Victory (void);
|
||||
|
||||
|
||||
@@ -34,9 +34,6 @@ LoadMasterShipList (void)
|
||||
RES_INSTANCE ri;
|
||||
RES_PACKAGE rp;
|
||||
|
||||
if (master_q.head != 0)
|
||||
return;
|
||||
|
||||
rt = GET_TYPE (ARILOU_SHIP_INDEX);
|
||||
ri = GET_INSTANCE (ARILOU_SHIP_INDEX);
|
||||
rp = GET_PACKAGE (ARILOU_SHIP_INDEX);
|
||||
@@ -94,9 +91,6 @@ if (master_q.head != 0)
|
||||
InsertQueue (&master_q, hBuiltShip, hStarShip);
|
||||
}
|
||||
}
|
||||
|
||||
TaskSwitch ();
|
||||
// XXX: what is this doing here?
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+140
-117
@@ -257,138 +257,161 @@ else if (InputState & DEVICE_EXIT) return (FALSE);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
StartGame (void)
|
||||
RestartMenu (PMENU_STATE pMS)
|
||||
{
|
||||
MENU_STATE MenuState;
|
||||
DWORD TimeOut;
|
||||
BYTE black_buf[1];
|
||||
|
||||
TimedOut:
|
||||
LastActivity = GLOBAL (CurrentActivity);
|
||||
GLOBAL (CurrentActivity) = 0;
|
||||
if (LastActivity == (ACTIVITY)~0)
|
||||
ReinitQueue (&race_q[0]);
|
||||
ReinitQueue (&race_q[1]);
|
||||
|
||||
black_buf[0] = FadeAllToBlack;
|
||||
|
||||
SetContext (ScreenContext);
|
||||
|
||||
GLOBAL (CurrentActivity) |= CHECK_ABORT;
|
||||
if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
|
||||
&& GET_GAME_STATE (UTWIG_BOMB_ON_SHIP)
|
||||
&& !GET_GAME_STATE (UTWIG_BOMB))
|
||||
{ // player blew himself up with Utwig bomb
|
||||
BYTE white_buf[] = {FadeAllToWhite};
|
||||
|
||||
SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0);
|
||||
|
||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)white_buf,
|
||||
ONE_SECOND / 8) + ONE_SECOND / 60);
|
||||
SetContextBackGroundColor (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
|
||||
ClearDrawable ();
|
||||
FlushColorXForms ();
|
||||
|
||||
TimeOut = ONE_SECOND / 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
Introduction ();
|
||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
TimeOut = ONE_SECOND / 2;
|
||||
|
||||
if (LOBYTE (LastActivity) == WON_LAST_BATTLE)
|
||||
{
|
||||
TFB_Abort ();
|
||||
GLOBAL (CurrentActivity) = WON_LAST_BATTLE;
|
||||
Victory ();
|
||||
Credits (TRUE);
|
||||
|
||||
FreeGameData ();
|
||||
|
||||
TimeOut = ONE_SECOND / 2;
|
||||
GLOBAL (CurrentActivity) = CHECK_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
memset ((PMENU_STATE)&MenuState, 0, sizeof (MenuState));
|
||||
LastActivity = NextActivity = 0;
|
||||
|
||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut));
|
||||
if (TimeOut == ONE_SECOND / 8)
|
||||
SleepThread (ONE_SECOND * 3);
|
||||
DrawRestartMenuGraphic (pMS);
|
||||
FlushInput ();
|
||||
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
|
||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
|
||||
DoInput (pMS, TRUE);
|
||||
|
||||
StopMusic ();
|
||||
if (pMS->hMusic)
|
||||
{
|
||||
DestroyMusic (pMS->hMusic);
|
||||
pMS->hMusic = 0;
|
||||
}
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetFlashRect ((PRECT)0, (FRAME)0);
|
||||
UnlockMutex (GraphicsLock);
|
||||
DestroyDrawable (ReleaseDrawable (pMS->CurFrame));
|
||||
|
||||
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||
return (FALSE); // timed out
|
||||
|
||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
return (FALSE); // quit
|
||||
|
||||
TimeOut = XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND / 2);
|
||||
|
||||
SleepThreadUntil (TimeOut);
|
||||
FlushColorXForms ();
|
||||
|
||||
SeedRandomNumbers ();
|
||||
|
||||
return (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
TryStartGame (void)
|
||||
{
|
||||
MENU_STATE MenuState;
|
||||
|
||||
LastActivity = GLOBAL (CurrentActivity);
|
||||
GLOBAL (CurrentActivity) = 0;
|
||||
|
||||
memset (&MenuState, 0, sizeof (MenuState));
|
||||
MenuState.InputFunc = DoRestart;
|
||||
|
||||
{
|
||||
DWORD TimeOut;
|
||||
BYTE black_buf[1];
|
||||
|
||||
TryAgain:
|
||||
ReinitQueue (&race_q[0]);
|
||||
ReinitQueue (&race_q[1]);
|
||||
|
||||
black_buf[0] = FadeAllToBlack;
|
||||
|
||||
SetContext (ScreenContext);
|
||||
|
||||
GLOBAL (CurrentActivity) |= CHECK_ABORT;
|
||||
if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
|
||||
&& GET_GAME_STATE (UTWIG_BOMB_ON_SHIP)
|
||||
&& !GET_GAME_STATE (UTWIG_BOMB))
|
||||
{
|
||||
BYTE white_buf[] = {FadeAllToWhite};
|
||||
|
||||
SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0);
|
||||
|
||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)white_buf,
|
||||
ONE_SECOND / 8) + ONE_SECOND / 60);
|
||||
SetContextBackGroundColor (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
|
||||
ClearDrawable ();
|
||||
FlushColorXForms ();
|
||||
|
||||
TimeOut = ONE_SECOND / 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeOut = ONE_SECOND / 2;
|
||||
#ifdef NOTYET
|
||||
LastActivity = WON_LAST_BATTLE;
|
||||
#endif /* NOTYET */
|
||||
if (LOBYTE (LastActivity) == WON_LAST_BATTLE)
|
||||
{
|
||||
GLOBAL (CurrentActivity) = WON_LAST_BATTLE;
|
||||
Victory ();
|
||||
InitGameKernel ();
|
||||
Credits (TRUE);
|
||||
|
||||
FreeGameData ();
|
||||
|
||||
TimeOut = ONE_SECOND / 2;
|
||||
GLOBAL (CurrentActivity) = CHECK_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
LastActivity = NextActivity = 0;
|
||||
|
||||
{
|
||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut));
|
||||
if (TimeOut == ONE_SECOND / 8)
|
||||
SleepThread (ONE_SECOND * 3);
|
||||
DrawRestartMenuGraphic (&MenuState);
|
||||
FlushInput ();
|
||||
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
|
||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
|
||||
DoInput ((PVOID)&MenuState, TRUE);
|
||||
|
||||
StopMusic ();
|
||||
if (MenuState.hMusic)
|
||||
{
|
||||
DestroyMusic (MenuState.hMusic);
|
||||
MenuState.hMusic = 0;
|
||||
}
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetFlashRect ((PRECT)0, (FRAME)0);
|
||||
UnlockMutex (GraphicsLock);
|
||||
DestroyDrawable (ReleaseDrawable (MenuState.CurFrame));
|
||||
|
||||
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||
goto TimedOut;
|
||||
|
||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
{
|
||||
TFB_Abort ();
|
||||
}
|
||||
|
||||
TimeOut = XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND / 2);
|
||||
}
|
||||
|
||||
SleepThreadUntil (TimeOut);
|
||||
FlushColorXForms ();
|
||||
|
||||
SeedRandomNumbers ();
|
||||
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE)
|
||||
while (!RestartMenu (&MenuState))
|
||||
{ // spin until a game is started or loaded
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE &&
|
||||
!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||
{
|
||||
FreeGameData ();
|
||||
Melee ();
|
||||
MenuState.Initialized = FALSE;
|
||||
goto TryAgain;
|
||||
}
|
||||
|
||||
{
|
||||
extern STAR_DESC starmap_array[];
|
||||
extern const BYTE element_array[];
|
||||
extern const PlanetFrame planet_array[];
|
||||
|
||||
star_array = starmap_array;
|
||||
Elements = element_array;
|
||||
PlanData = planet_array;
|
||||
}
|
||||
|
||||
PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING;
|
||||
PlayerControl[1] = COMPUTER_CONTROL | AWESOME_RATING;
|
||||
SetPlayerInput ();
|
||||
return (TRUE);
|
||||
else if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||
{ // timed out
|
||||
BYTE black_buf[] = {FadeAllToBlack};
|
||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf,
|
||||
ONE_SECOND / 2));
|
||||
return (FALSE);
|
||||
}
|
||||
else if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
{ // quit
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
StartGame (void)
|
||||
{
|
||||
while (!TryStartGame ())
|
||||
{
|
||||
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||
{ // timed out
|
||||
GLOBAL (CurrentActivity) = 0;
|
||||
SplashScreen (0);
|
||||
Credits (FALSE);
|
||||
}
|
||||
|
||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
return (FALSE); // quit
|
||||
}
|
||||
|
||||
if (LastActivity & CHECK_RESTART)
|
||||
{ // starting a new game
|
||||
Introduction ();
|
||||
}
|
||||
|
||||
{
|
||||
extern STAR_DESC starmap_array[];
|
||||
extern const BYTE element_array[];
|
||||
extern const PlanetFrame planet_array[];
|
||||
|
||||
star_array = starmap_array;
|
||||
Elements = element_array;
|
||||
PlanData = planet_array;
|
||||
}
|
||||
|
||||
PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING;
|
||||
PlayerControl[1] = COMPUTER_CONTROL | AWESOME_RATING;
|
||||
SetPlayerInput ();
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "restart.h"
|
||||
#include "starbase.h"
|
||||
#include "setup.h"
|
||||
#include "master.h"
|
||||
#include "controls.h"
|
||||
#include "starcon.h"
|
||||
#include "uqmdebug.h"
|
||||
#include "libs/tasklib.h"
|
||||
@@ -75,6 +77,20 @@ arilou_gate_task(void *data)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
BackgroundInitKernel (DWORD TimeOut)
|
||||
{
|
||||
LoadMasterShipList ();
|
||||
TaskSwitch ();
|
||||
InitGameKernel ();
|
||||
|
||||
while ((GetTimeCounter () <= TimeOut) &&
|
||||
!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||
{
|
||||
UpdateInputState ();
|
||||
TaskSwitch ();
|
||||
}
|
||||
}
|
||||
|
||||
#define DEBUG_PSYTRON 0
|
||||
|
||||
@@ -127,6 +143,10 @@ while (--ac > 0)
|
||||
fprintf (stderr, "We've loaded the Kernel\n");
|
||||
|
||||
Logo ();
|
||||
|
||||
GLOBAL (CurrentActivity) = 0;
|
||||
// show splash and init the kernel in the meantime
|
||||
SplashScreen (BackgroundInitKernel);
|
||||
|
||||
// OpenJournal ();
|
||||
while (StartGame ())
|
||||
@@ -249,6 +269,8 @@ while (--ac > 0)
|
||||
UninitSIS ();
|
||||
}
|
||||
// CloseJournal ();
|
||||
|
||||
FreeGameData ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -256,6 +278,10 @@ while (--ac > 0)
|
||||
}
|
||||
FreeKernel ();
|
||||
|
||||
// XXX: the abort can now be changed to something cleaner;
|
||||
// something to terminate the for(;;) loop in main()
|
||||
TFB_Abort ();
|
||||
|
||||
(void) threadArg; /* Satisfying compiler (unused parameter) */
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user