Removed references to pMenuState from comm (required parameter carried forward); some header file cleanups; comments and minor cleanup of Starbase

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3318 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-11-18 05:39:40 +00:00
parent 2e14cd01f0
commit fcb537e47f
23 changed files with 171 additions and 94 deletions
+61 -53
View File
@@ -50,10 +50,11 @@
LOCDATA CommData;
int cur_comm;
UNICODE shared_phrase_buf[2048];
static BOOLEAN TalkingFinished;
static CommIntroMode curIntroMode = CIM_DEFAULT;
static TimeCount fadeTime;
typedef struct response_entry
{
@@ -686,6 +687,47 @@ FlushTalkSegue (void)
TalkingFinished = TRUE;
}
static void
CommIntroTransition (void)
{
if (curIntroMode == CIM_CROSSFADE_SCREEN)
{
ScreenTransition (3, NULL);
UnbatchGraphics ();
}
else if (curIntroMode == CIM_CROSSFADE_SPACE)
{
RECT r;
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT;
ScreenTransition (3, &r);
UnbatchGraphics ();
}
else if (curIntroMode == CIM_CROSSFADE_WINDOW)
{
ScreenTransition (3, &CommWndRect);
UnbatchGraphics ();
}
else if (curIntroMode == CIM_FADE_IN_SCREEN)
{
BYTE clut_buf[] = {FadeAllToColor};
UnbatchGraphics ();
XFormColorMap ((COLORMAPPTR)clut_buf, fadeTime);
}
else
{ // Uknown transition
// Have to unbatch anyway or no more graphics, ever
UnbatchGraphics ();
assert (0 && "Unknown comm intro transition");
}
// Reset the mode for next time. Everything that needs a
// different one will let us know.
curIntroMode = CIM_DEFAULT;
}
void
AlienTalkSegue (COUNT wait_track)
{
@@ -703,43 +745,7 @@ AlienTalkSegue (COUNT wait_track)
DrawAlienFrame (NULL, 0, TRUE);
UpdateSpeechGraphics (TRUE);
if (LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE
|| (!GET_GAME_STATE (PLAYER_HYPNOTIZED)
&& !GET_GAME_STATE (CHMMR_EMERGING)
&& GET_GAME_STATE (CHMMR_BOMB_STATE) != 2
&& (pMenuState == 0 || !GET_GAME_STATE (MOONBASE_ON_SHIP)
|| GET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER))))
{
RECT r;
if (pMenuState == 0 &&
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE)
{
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT;
ScreenTransition (3, &r);
}
else
{
ScreenTransition (3, &CommWndRect);
}
UnbatchGraphics ();
}
else
{
BYTE clut_buf[] = {FadeAllToColor};
UnbatchGraphics ();
if (GET_GAME_STATE (MOONBASE_ON_SHIP)
|| GET_GAME_STATE (CHMMR_BOMB_STATE) == 2)
XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND * 2);
else if (GET_GAME_STATE (CHMMR_EMERGING))
XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND * 2);
else
XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND * 5);
}
CommIntroTransition ();
pCurInputState->Initialized = TRUE;
PlayMusic (CommData.AlienSong, TRUE, 1);
@@ -1238,30 +1244,23 @@ HailAlien (void)
SetContextClipRect (&r);
CommWndRect.corner = r.corner;
if (pMenuState == 0)
{
RepairSISBorder ();
UnlockMutex (GraphicsLock);
DrawMenuStateStrings ((BYTE)~0, 1);
LockMutex (GraphicsLock);
}
else /* in starbase */
{
DrawSISFrame ();
if (GET_GAME_STATE (STARBASE_AVAILABLE))
{
// TODO: find a better way to do this, perhaps set the titles
// forward from callers.
if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) == (BYTE)~0
&& GET_GAME_STATE (STARBASE_AVAILABLE))
{ // Talking to allied Starbase
DrawSISMessage (GAME_STRING (STARBASE_STRING_BASE + 1));
// "Starbase Commander"
DrawSISTitle (GAME_STRING (STARBASE_STRING_BASE + 0));
// "Starbase"
}
else
{
{ // Default titles: star name + planet name
DrawSISMessage (NULL);
DrawSISTitle (GLOBAL_SIS (PlanetName));
}
}
}
DrawSISComWindow ();
}
@@ -1297,6 +1296,13 @@ HailAlien (void)
pCurInputState = 0;
}
void
SetCommIntroMode (CommIntroMode newMode, TimeCount howLong)
{
curIntroMode = newMode;
fadeTime = howLong;
}
COUNT
InitCommunication (CONVERSATION which_comm)
{
@@ -1400,9 +1406,7 @@ InitCommunication (CONVERSATION which_comm)
if (status == HAIL)
{
cur_comm = which_comm;
HailAlien ();
cur_comm = 0;
}
else if (LocDataPtr)
{ // only when comm initied successfully
@@ -1417,10 +1421,14 @@ InitCommunication (CONVERSATION which_comm)
status = 0;
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
// The Sa-Matra battle is skipped when Cyborg is enabled.
// Most likely because the Cyborg is too dumb to know what
// to do in this battle.
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE
&& (GLOBAL (glob_flags) & CYBORG_ENABLED))
ReinitQueue (&GLOBAL (npc_built_ship_q));
// Clear the location flags
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 0);
status = (GET_GAME_STATE (BATTLE_SEGUE)
&& GetHeadLink (&GLOBAL (npc_built_ship_q)));
+21
View File
@@ -20,6 +20,8 @@
#include "globdata.h"
#include "libs/compiler.h"
#include "libs/gfxlib.h"
#include "commglue.h"
// for CONVERSATION
#ifdef COMM_INTERNAL
@@ -98,8 +100,16 @@ signaledStopTalkingAnim (void)
#endif
#define TEXT_X_OFFS 1
#define TEXT_Y_OFFS 1
#define SIS_TEXT_WIDTH (SIS_SCREEN_WIDTH - (TEXT_X_OFFS << 1))
extern void init_communication (void);
extern void uninit_communication (void);
extern COUNT InitCommunication (CONVERSATION which_comm);
extern void RaceCommunication (void);
extern void AlienTalkSegue (COUNT wait_track);
BOOLEAN getLineWithinWidth(TEXT *pText, const unsigned char **startNext,
SIZE maxWidth, COUNT maxChars);
@@ -108,6 +118,17 @@ extern BOOLEAN HaveSubtitlesChanged (void);
extern RECT CommWndRect; /* comm window rect */
typedef enum
{
CIM_CROSSFADE_SPACE,
CIM_CROSSFADE_WINDOW,
CIM_CROSSFADE_SCREEN,
CIM_FADE_IN_SCREEN,
CIM_DEFAULT = CIM_CROSSFADE_SPACE,
} CommIntroMode;
extern void SetCommIntroMode (CommIntroMode, TimeCount howLong);
extern void EnableTalkingAnim (BOOLEAN enable);
#endif /* _COMM_H */
+1
View File
@@ -577,6 +577,7 @@ Intro (void)
}
else
{
SetCommIntroMode (CIM_FADE_IN_SCREEN, ONE_SECOND * 2);
NPCPhrase (WE_ARE_FREE);
if (NumVisits)
-1
View File
@@ -20,7 +20,6 @@
#include "uqm/colors.h"
#include "uqm/comm.h"
#include "uqm/commglue.h"
#include "uqm/encount.h"
#include "libs/reslib.h"
#endif /* _COMMALL_H */
+3
View File
@@ -26,6 +26,9 @@
#include "libs/inplib.h"
#include "libs/mathlib.h"
// XXX: temporary, for SOL_X/SOL_Y
#include "uqm/races.h"
#define NUM_HISTORY_ITEMS 9
#define NUM_EVENT_ITEMS 8
+1
View File
@@ -429,6 +429,7 @@ Intro (void)
}
else if (GET_GAME_STATE (PLAYER_HYPNOTIZED))
{
SetCommIntroMode (CIM_FADE_IN_SCREEN, ONE_SECOND * 5);
UrquanHypno ((RESPONSE_REF)0);
}
else
-1
View File
@@ -54,7 +54,6 @@ typedef enum {
} CONVERSATION;
extern LOCDATA CommData;
extern int cur_comm;
extern UNICODE shared_phrase_buf[2048];
#define PLAYER_SAID(r,i) ((r)==(i))
+1 -2
View File
@@ -19,11 +19,9 @@
#include "credits.h"
#include "controls.h"
#include "encount.h"
#include "options.h"
#include "oscill.h"
#include "comm.h"
#include "commglue.h"
#include "resinst.h"
#include "nameref.h"
#include "settings.h"
@@ -617,6 +615,7 @@ OutTakes (void)
for (i = 0; (i < NUM_OUTTAKES) &&
!(GLOBAL (CurrentActivity) & CHECK_ABORT); i++)
{
SetCommIntroMode (CIM_CROSSFADE_WINDOW, 0);
InitCommunication (outtake_list[i]);
}
+6 -6
View File
@@ -19,11 +19,12 @@
#ifndef _ENCOUNT_H
#define _ENCOUNT_H
// XXX: temporary, for CONVERSATION
#include "commglue.h"
#include "displist.h"
#include "libs/gfxlib.h"
#include "planets/planets.h"
#include "races.h"
#include "element.h"
typedef HLINK HENCOUNTER;
@@ -124,10 +125,7 @@ enum
#define UMGAH_DEFINED TALKING_PET_DEFINED
#define TEXT_X_OFFS 1
#define TEXT_Y_OFFS 1
#define SIS_TEXT_WIDTH (SIS_SCREEN_WIDTH - (TEXT_X_OFFS << 1))
// XXX: The stuff till EOC does not belong here
extern STAR_DESC *CurStarDescPtr;
extern STAR_DESC *star_array;
@@ -137,6 +135,7 @@ extern STAR_DESC* FindStar (STAR_DESC *pLastStar, POINT *puniverse,
SIZE xbounds, SIZE ybounds);
extern void GetClusterName (const STAR_DESC *pSD, UNICODE buf[]);
// <<< EOC
enum
{
@@ -149,8 +148,9 @@ extern void EncounterBattle (void);
extern void BuildBattle (COUNT which_player);
extern COUNT InitEncounter (void);
extern COUNT UninitEncounter (void);
// XXX: in comm.h, temporary, until solsys generation code is redone
extern COUNT InitCommunication (CONVERSATION which_comm);
extern void RaceCommunication (void);
extern void GenerateSOL (BYTE control);
extern void GenerateShofixti (BYTE control);
+1
View File
@@ -19,6 +19,7 @@
#include "build.h"
#include "clock.h"
// XXX: for CurStarDescPtr and XXX_DEFINED constants
#include "encount.h"
#include "globdata.h"
#include "hyper.h"
+2
View File
@@ -21,7 +21,9 @@
#include "build.h"
#include "colors.h"
#include "commglue.h"
// for CommData
#include "controls.h"
// XXX: for FindStart(), GetClusterName()
#include "encount.h"
#include "planets/lander.h"
#include "gamestr.h"
+1
View File
@@ -17,6 +17,7 @@
*/
#include "build.h"
// XXX: for CurStarDescPtr and XXX_DEFINED constants
#include "encount.h"
#include "libs/file.h"
#include "globdata.h"
+1
View File
@@ -25,6 +25,7 @@
#include "process.h"
#include "grpinfo.h"
#include "encount.h"
// for EncounterGroup, EncounterRace
#include "libs/mathlib.h"
-1
View File
@@ -17,7 +17,6 @@
*/
#include "colors.h"
#include "commglue.h"
#include "controls.h"
#include "options.h"
#include "setup.h"
+2
View File
@@ -16,8 +16,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// XXX: for XXX_DEFINED constants
#include "encount.h"
#include "resinst.h"
#include "planets/planets.h"
#include "planets/elemdata.h"
+1
View File
@@ -23,6 +23,7 @@
#include "../cons_res.h"
#include "../controls.h"
#include "../colors.h"
// XXX: for CurStarDescPtr and XXX_DEFINED
#include "../encount.h"
#include "../process.h"
#include "../gamestr.h"
+1
View File
@@ -17,6 +17,7 @@
*/
#include "planets.h"
// XXX: for CurStarDescPtr
#include "../encount.h"
#include "libs/compiler.h"
#include "libs/mathlib.h"
+1
View File
@@ -19,6 +19,7 @@
#include "scan.h"
#include "../colors.h"
#include "../controls.h"
// XXX: for stuff that does not belong there
#include "../encount.h"
#include "../gameopt.h"
#include "../gamestr.h"
+1
View File
@@ -22,6 +22,7 @@
#include "../cons_res.h"
#include "../controls.h"
#include "../encount.h"
// for EncounterGroup
#include "../gamestr.h"
#include "../nameref.h"
#include "../resinst.h"
+1
View File
@@ -21,6 +21,7 @@
#include "colors.h"
#include "controls.h"
#include "credits.h"
// XXX: for star_array[]
#include "encount.h"
#include "fmv.h"
#include "gamestr.h"
+2 -1
View File
@@ -17,7 +17,8 @@
*/
#include "colors.h"
#include "commglue.h"
#include "races.h"
// XXX: including encount.h for stuff that does not belong there
#include "encount.h"
#include "gamestr.h"
#include "options.h"
+53 -19
View File
@@ -19,7 +19,9 @@
#include "build.h"
#include "colors.h"
#include "controls.h"
// XXX: for CurStarDescPtr
#include "encount.h"
#include "comm.h"
#include "gamestr.h"
#include "load.h"
#include "starbase.h"
@@ -34,6 +36,8 @@
MENU_STATE *pMenuState;
static void CleanupAfterStarBase (void);
static void
DrawBaseStateStrings (STARBASE_STATE OldState, STARBASE_STATE NewState)
{
@@ -289,6 +293,8 @@ rotateStarbase (MENU_STATE *pMS, FRAME AniFrame)
BOOLEAN
DoStarBase (MENU_STATE *pMS)
{
// XXX: This function is full of hacks and otherwise strange code
if (GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
{
pMS->CurState = DEPART_BASE;
@@ -344,9 +350,7 @@ DoStarBase (MENU_STATE *pMS)
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
else if (PulsedInputState.menu[KEY_MENU_SELECT]
|| GET_GAME_STATE (MOONBASE_ON_SHIP)
|| GET_GAME_STATE (CHMMR_BOMB_STATE) == 2)
else if (PulsedInputState.menu[KEY_MENU_SELECT])
{
ExitStarBase:
DestroyDrawable (ReleaseDrawable (pMS->CurFrame));
@@ -372,6 +376,8 @@ ExitStarBase:
{
FlushInput ();
InitCommunication (COMMANDER_CONVERSATION);
// XXX: InitCommunication() clears these flags, and we need them
// This marks that we are in Starbase.
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
}
else
@@ -453,22 +459,31 @@ VisitStarBase (void)
CONTEXT OldContext;
StatMsgMode prevMsgMode = SMM_UNDEFINED;
// XXX: This should probably be moved out to Starcon2Main()
if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 2)
{
CurStarDescPtr = 0;
goto TimePassage;
{ // We were just transported by Chmmr to the Starbase
// Force a reload of the SolarSys
CurStarDescPtr = NULL;
// This marks that we are in Starbase.
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
}
else if (!GET_GAME_STATE (STARBASE_AVAILABLE))
if (!GET_GAME_STATE (STARBASE_AVAILABLE))
{
HSHIPFRAG hStarShip;
SHIP_FRAGMENT *FragPtr;
pMenuState = 0;
// Unallied Starbase conversation
SetCommIntroMode (CIM_CROSSFADE_SCREEN, 0);
InitCommunication (COMMANDER_CONVERSATION);
if (!GET_GAME_STATE (PROBE_ILWRATH_ENCOUNTER)
|| (GLOBAL (CurrentActivity) & CHECK_ABORT))
goto ExitStarBase;
{
CleanupAfterStarBase ();
return;
}
/* Create an Ilwrath ship responding to the Ur-Quan
* probe's broadcast */
@@ -483,18 +498,18 @@ VisitStarBase (void)
InitCommunication (ILWRATH_CONVERSATION);
if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
|| (GLOBAL (CurrentActivity) & CHECK_ABORT))
return;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
return; // Killed by Ilwrath
// After Ilwrath battle, about-to-ally Starbase conversation
{
pMenuState = &MenuState;
SetCommIntroMode (CIM_CROSSFADE_SCREEN, 0);
InitCommunication (COMMANDER_CONVERSATION);
TimePassage:
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return;
// XXX: InitCommunication() clears these flags, and we need them
// This marks that we are in Starbase.
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
DoTimePassage ();
if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)
return; // You are now dead! Thank you!
}
}
@@ -504,11 +519,23 @@ TimePassage:
memset (&MenuState, 0, sizeof (MenuState));
MenuState.InputFunc = DoStarBase;
if (GET_GAME_STATE (MOONBASE_ON_SHIP)
|| GET_GAME_STATE (CHMMR_BOMB_STATE) == 2)
{
MenuState.Initialized = TRUE;
MenuState.CurState = TALK_COMMANDER;
{ // Go immediately into a conversation with the Commander when the
// Starbase becomes available for the first time, or after Chmmr
// install the bomb.
DoTimePassage ();
if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)
return; // You are now dead! Thank you! (killed by Kohr-Ah)
SetCommIntroMode (CIM_FADE_IN_SCREEN, ONE_SECOND * 2);
InitCommunication (COMMANDER_CONVERSATION);
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return;
// XXX: InitCommunication() clears these flags, and we need them
// This marks that we are in Starbase.
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
}
OldContext = SetContext (ScreenContext);
@@ -518,10 +545,17 @@ TimePassage:
pMenuState = 0;
SetStatusMessageMode (prevMsgMode);
ExitStarBase:
CleanupAfterStarBase ();
}
static void
CleanupAfterStarBase (void)
{
if (!(GLOBAL (CurrentActivity) & (CHECK_LOAD | CHECK_ABORT)))
{
// Mark as not in Starbase anymore
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 0);
// Fake a load so Starcon2Main takes us to IP
GLOBAL (CurrentActivity) = CHECK_LOAD;
NextActivity = MAKE_WORD (IN_INTERPLANETARY, 0)
| START_INTERPLANETARY;
+1 -1
View File
@@ -18,7 +18,7 @@
#include <stdlib.h>
#include "encount.h"
#include "comm.h"
#include "battle.h"
#include "fmv.h"
#include "gameev.h"