Updates to play sections

This commit is contained in:
jsalmon3 2003-02-16 02:29:05 +00:00
parent f222d3cde8
commit 63e5c13bfc
9 changed files with 161 additions and 109 deletions

View file

@ -434,7 +434,7 @@ global void ShowIntro(const Intro *intro)
CallbackMusicOff();
StopMusic();
PlaySection = PlaySectionBriefing;
CurrentPlaySection = PlaySectionBriefing;
CDRomCheck(NULL);
if( intro->VoiceFile[0] ) {
PlayFile(intro->VoiceFile[0]);

View file

@ -10,7 +10,7 @@
//
/**@name sound.h - The sound header file. */
//
// (c) Copyright 1998-2002 by Lutz Sammer and Fabrice Rossi
// (c) Copyright 1998-2003 by Lutz Sammer and Fabrice Rossi
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
@ -67,6 +67,35 @@ typedef struct _game_sound_ {
SoundConfig OrcRescue; /// rescue units
} GameSound;
typedef enum _play_section_type_ {
PlaySectionGame, /// Game
PlaySectionBriefing, /// Briefing
PlaySectionStats, /// Stats
PlaySectionMainMenu, /// Main menu
} PlaySectionType;
typedef enum _play_section_order_ {
PlaySectionOrderAll, /// Sequential order
PlaySectionOrderRandom, /// Random order
} PlaySectionOrder;
typedef struct _play_section_ {
char *Race; /// Race, NULL if for all races
PlaySectionType Type; /// Type
unsigned long CDTracks; /// Bit field of cd tracks. 32 enough?
PlaySectionOrder CDOrder; /// CD order
char **Files; /// Files
PlaySectionOrder FileOrder; /// File order
} PlaySection;
typedef enum _cd_modes_ {
CDModeStopped = -1, /// Stopped
CDModeOff, /// Off
CDModeAll, /// All
CDModeRandom, /// Random
CDModeDefined, /// Defined
} CDModes;
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
@ -83,6 +112,12 @@ extern GameSound GameSounds; /// Game sound configuration
extern int PlayingMusic; /// flag true if playing music
extern int CallbackMusic; /// flag true callback ccl if stops
extern PlaySection *PlaySections; /// Play sections
extern int NumPlaySections; /// Number of play sections
extern PlaySectionType CurrentPlaySection; /// Current play section type
extern CDModes CDMode; /// CD mode
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/

View file

@ -10,7 +10,7 @@
//
/**@name sound_server.h - The sound server header file. */
//
// (c) Copyright 1998-2002 by Lutz Sammer and Fabrice Rossi
// (c) Copyright 1998-2003 by Lutz Sammer and Fabrice Rossi
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
@ -234,21 +234,6 @@ extern unsigned AllocatedSoundMemory;
extern unsigned CompressedSoundMemory;
#endif
/// cd play mode, ":off" ":random" ":all" or ":defined"
enum _cd_mode_ {
CDModeStopped = -1,
CDModeOff,
CDModeAll,
CDModeRandom,
CDModeDefined,
} CDMode;
/// FIXME: docu
enum _play_section_ {
PlaySectionMainMenu,
PlaySectionGame,
PlaySectionStats,
PlaySectionBriefing,
} PlaySection;
#if defined(USE_SDLCD) || defined(USE_LIBCDA) || defined(USE_CDDA)
/// FIXME: docu
extern int CDTrack;

View file

@ -10,7 +10,7 @@
//
/**@name music.c - Background music support */
//
// (c) Copyright 2002 by Lutz Sammer
// (c) Copyright 2002-2003 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
@ -355,7 +355,7 @@ global int PlayCDRom(int name)
if (name == CDModeDefined) {
CDMode = CDModeDefined;
track = cd_current_track();
if (PlaySection == PlaySectionStats) {
if (CurrentPlaySection == PlaySectionStats) {
if (GameResult == GameVictory) {
if (!ThisPlayer->Race && track != 8) {
cd_play(8);
@ -369,20 +369,20 @@ global int PlayCDRom(int name)
cd_play(17);
}
}
} else if (PlaySection == PlaySectionBriefing) {
} else if (CurrentPlaySection == PlaySectionBriefing) {
if (!ThisPlayer->Race && track != 7) {
cd_play(7);
} else if (ThisPlayer->Race && track != 15) {
cd_play(15);
}
} else if ((PlaySection == PlaySectionMainMenu) && track != 15) {
} else if (CurrentPlaySection == PlaySectionMainMenu && track != 15) {
cd_play(15);
} else if ((PlaySection == PlaySectionGame) &&
} else if (CurrentPlaySection == PlaySectionGame &&
!ThisPlayer->Race && (track < 3 || track > 6)) {
do CDTrack = (MyRand() % NumCDTracks) + 3;
while (CDTrack < 3 || CDTrack > 7);
cd_play(CDTrack);
} else if ((PlaySection == PlaySectionGame) &&
} else if (CurrentPlaySection == PlaySectionGame &&
ThisPlayer->Race && (track < 10 || track > 14)) {
do CDTrack = (MyRand() % NumCDTracks) + 9;
while (CDTrack < 11 || CDTrack > 14);

View file

@ -10,7 +10,7 @@
//
/**@name ccl_sound.c - The sound ccl functions. */
//
// (c) Copyright 1999-2002 by Lutz Sammer and Fabrice Rossi
// (c) Copyright 1999-2003 by Lutz Sammer and Fabrice Rossi
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
@ -376,107 +376,128 @@ local SCM CclSetMusicVolume(SCM volume)
local SCM CclSetCdMode(SCM mode)
{
#if defined(USE_SDLCD) || defined(USE_LIBCDA) || defined(USE_CDDA)
int cdmode;
char *str = gh_scm2newstr(mode, NULL);
CDModes cdmode;
if (!strcmp(str, "all")) {
cdmode = CDModeAll;
} else if (!strcmp(str, "random")) {
cdmode = CDModeRandom;
} else if (!strcmp(str, "defined")) {
cdmode = CDModeDefined;
if( gh_eq_p(mode,gh_symbol2scm("all")) ) {
cdmode=CDModeAll;
} else if( gh_eq_p(mode,gh_symbol2scm("random")) ) {
cdmode=CDModeRandom;
} else if( gh_eq_p(mode,gh_symbol2scm("defined")) ) {
cdmode=CDModeDefined;
} else {
free(str);
return mode;
errl("Unsupported tag",mode);
}
free(str);
PlayCDRom(cdmode);
#endif
return mode;
}
/**
** Define play sections
*/
local SCM CclDefinePlaySections(SCM list)
{
SCM value, sublist, sublist2, temp;
enum _race_ { racealliance, racemythical } race = -1;
enum _type_ { typegame, typebriefing, typestats, typemainmenu } type = -1;
enum _order_ { orderall, orderrandom } order = -1;
long tracks = 0;
SCM value;
SCM sublist;
PlaySection *p;
int i;
char *filename;
while ( !gh_null_p(list) ) {
value = gh_car(list);
list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("race"))) {
value = gh_car(list);
sublist = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("alliance"))) {
race = racealliance;
} else if (gh_eq_p(value, gh_symbol2scm("mythical"))) {
race = racemythical;
++NumPlaySections;
PlaySections=realloc(PlaySections,NumPlaySections*sizeof(PlaySection));
p=PlaySections+NumPlaySections-1;
memset(p,0,sizeof(PlaySection));
while( !gh_null_p(list) ) {
value=gh_car(list);
list=gh_cdr(list);
if( gh_eq_p(value,gh_symbol2scm("race")) ) {
value=gh_car(list);
list=gh_cdr(list);
p->Race=gh_scm2newstr(value,NULL);
} else if( gh_eq_p(value,gh_symbol2scm("type")) ) {
value=gh_car(list);
list=gh_cdr(list);
if( gh_eq_p(value, gh_symbol2scm("game")) ) {
p->Type=PlaySectionGame;
} else if( gh_eq_p(value,gh_symbol2scm("briefing")) ) {
p->Type=PlaySectionBriefing;
} else if( gh_eq_p(value,gh_symbol2scm("stats")) ) {
p->Type=PlaySectionStats;
} else if( gh_eq_p(value,gh_symbol2scm("main-menu")) ) {
p->Type=PlaySectionMainMenu;
} else {
errl("Unsupported tag",value);
}
}
if (gh_eq_p(value, gh_symbol2scm("type"))) {
value = gh_car(list);
sublist = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("game"))) {
type = typegame;
} else if (gh_eq_p(value, gh_symbol2scm("briefing"))) {
type = typebriefing;
} else if (gh_eq_p(value, gh_symbol2scm("stats"))) {
type = typestats;
} else if (gh_eq_p(value, gh_symbol2scm("mainmenu"))) {
type = typemainmenu;
}
}
if (gh_eq_p(value, gh_symbol2scm("cd"))) {
sublist = gh_car(list);
list = gh_cdr(list);
while ( !gh_null_p(sublist) ) {
value = gh_car(sublist);
sublist = gh_cdr(sublist);
if (gh_eq_p(value, gh_symbol2scm("order"))) {
value = gh_car(list);
sublist = gh_cdr(sublist);
if (gh_eq_p(value, gh_symbol2scm("all"))) {
order = orderall;
} else if (gh_eq_p(value, gh_symbol2scm("random"))) {
order = orderrandom;
} else if( gh_eq_p(value,gh_symbol2scm("cd")) ) {
sublist=gh_car(list);
list=gh_cdr(list);
while( !gh_null_p(sublist) ) {
value=gh_car(sublist);
sublist=gh_cdr(sublist);
if( gh_eq_p(value,gh_symbol2scm("order")) ) {
value=gh_car(sublist);
sublist=gh_cdr(sublist);
if( gh_eq_p(value,gh_symbol2scm("all")) ) {
p->CDOrder=PlaySectionOrderAll;
} else if( gh_eq_p(value,gh_symbol2scm("random")) ) {
p->CDOrder=PlaySectionOrderRandom;
} else {
errl("Unsupported tag",value);
}
}
if (gh_eq_p(value, gh_symbol2scm("tracks"))) {
value = gh_car(sublist);
sublist = gh_cdr(sublist);
for (i = 0; i < gh_vector_length(value); ++i) {
temp = gh_vector_ref(value, gh_int2scm(i));
tracks = tracks | (1 << gh_scm2int(temp));
} else if( gh_eq_p(value,gh_symbol2scm("tracks")) ) {
SCM temp;
value=gh_car(sublist);
sublist=gh_cdr(sublist);
for( i=0; i<gh_vector_length(value); ++i ) {
temp=gh_vector_ref(value,gh_int2scm(i));
p->CDTracks|=(1<<gh_scm2int(temp));
}
} else {
errl("Unsupported tag",value);
}
}
}
if (gh_eq_p(value, gh_symbol2scm("no-cd"))) {
sublist = gh_car(list);
list = gh_cdr(list);
while ( !gh_null_p(sublist) ) {
value = gh_car(sublist);
sublist = gh_cdr(sublist);
if (gh_eq_p(value, gh_symbol2scm("files"))) {
sublist2 = gh_car(sublist);
sublist = gh_cdr(sublist);
while ( !gh_null_p(sublist2) ) {
value = gh_car(sublist2);
sublist2 = gh_cdr(sublist2);
filename = gh_scm2newstr(value, NULL);
printf("file %s\n", filename);
free(filename);
} else if( gh_eq_p(value,gh_symbol2scm("no-cd")) ) {
sublist=gh_car(list);
list=gh_cdr(list);
while( !gh_null_p(sublist) ) {
value=gh_car(sublist);
sublist=gh_cdr(sublist);
if( gh_eq_p(value,gh_symbol2scm("order")) ) {
value=gh_car(sublist);
sublist=gh_cdr(sublist);
if( gh_eq_p(value,gh_symbol2scm("all")) ) {
p->FileOrder=PlaySectionOrderAll;
} else if( gh_eq_p(value,gh_symbol2scm("random")) ) {
p->FileOrder=PlaySectionOrderRandom;
} else {
errl("Unsupported tag",value);
}
} else if( gh_eq_p(value,gh_symbol2scm("files")) ) {
SCM sublist2;
sublist2=gh_car(sublist);
sublist=gh_cdr(sublist);
i=0;
while( !gh_null_p(sublist2) ) {
value=gh_car(sublist2);
sublist2=gh_cdr(sublist2);
++i;
p->Files=realloc(p->Files,(i+1)*sizeof(char*));
p->Files[i-1]=gh_scm2newstr(value,NULL);
p->Files[i]=NULL;
}
} else {
errl("Unsupported tag",value);
}
}
} else {
errl("Unsupported tag",value);
}
}
return SCM_UNSPECIFIED;
}
/**

View file

@ -86,6 +86,12 @@ global GameSound GameSounds
#endif
;
global PlaySection *PlaySections; /// Play sections
global int NumPlaySections; /// Number of play sections
global PlaySectionType CurrentPlaySection; /// Current play section
global CDModes CDMode; /// CD mode
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/

View file

@ -11,7 +11,7 @@
/**@name sound_server.c - The sound server
** (hardware layer and so on) */
//
// (c) Copyright 1998-2002 by Lutz Sammer and Fabrice Rossi
// (c) Copyright 1998-2003 by Lutz Sammer and Fabrice Rossi
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
@ -1269,20 +1269,25 @@ global void QuitSound(void)
#endif // USE_SDLA
}
/**
** FIXME: docu
*/
global void QuitCD(void)
{
#if defined(USE_SDLCD)
if (CDMode != CDModeOff && CDMode != CDModeStopped)
if (CDMode != CDModeOff && CDMode != CDModeStopped) {
SDL_CDStop(CDRom);
CDMode = CDModeStopped;
}
if (CDMode != CDModeStopped) {
SDL_CDClose(CDRom);
CDMode = CDModeOff;
}
#elif defined(USE_LIBCDA)
if (CDMode != CDModeOff && CDMode != CDModeStopped)
if (CDMode != CDModeOff && CDMode != CDModeStopped) {
cd_stop();
CDMode = CDModeStopped;
}
if (CDMode == CDModeStopped) {
cd_close();
cd_exit();

View file

@ -639,7 +639,7 @@ global void GameMainLoop(void)
MultiPlayerReplayEachCycle();
PlaySection = PlaySectionGame;
CurrentPlaySection = PlaySectionGame;
CDRomCheck(NULL);
while( GameRunning ) {
@ -813,7 +813,7 @@ global void GameMainLoop(void)
}
if( GameResult==GameVictory || GameResult==GameDefeat ) {
PlaySection = PlaySectionStats;
CurrentPlaySection = PlaySectionStats;
CDRomCheck(NULL);
ShowStats();
}

View file

@ -1122,7 +1122,7 @@ global void MenuLoop(char* filename, WorldMap* map)
CleanModules();
CleanFonts();
PlaySection = PlaySectionMainMenu;
CurrentPlaySection = PlaySectionMainMenu;
LoadCcl(); // Reload the main config file