From e435acd4f0896a8504a55f4219c61c19993f8781 Mon Sep 17 00:00:00 2001 From: Martin Schaffner Date: Sat, 9 Oct 2004 15:59:28 +0000 Subject: [PATCH] use new macros PLAYING_BUILTIN_MISSION and EMULATING_D1 for accessing information about the current mission, for easier code refactorisation VS: ---------------------------------------------------------------------- --- ChangeLog | 7 +++++++ main/automap.c | 4 ++-- main/cntrlcen.c | 6 +++--- main/collide.c | 8 ++++---- main/endlevel.c | 15 ++++++--------- main/gamerend.c | 6 +++--- main/gameseq.c | 26 +++++++++++++------------- main/mission.h | 5 ++++- main/titles.c | 31 +++++++++++++++---------------- 9 files changed, 57 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b3000b0..58865bad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-10-09 Martin Schaffner + + * main/automap.c, main/cntrlcen.c, main/collide.c, main/endlevel.c, + main/gamerend.c, main/gameseq.c, main/mission.h, main/titles.c: + use new macros PLAYING_BUILTIN_MISSION and EMULATING_D1 for accessing + information about the current mission, for easier code refactorisation. + 2004-09-30 Martin Schaffner * cfile/cfile.c: simplify, reduce number of global vars diff --git a/main/automap.c b/main/automap.c index cb20521c..8a533cc8 100644 --- a/main/automap.c +++ b/main/automap.c @@ -1,4 +1,4 @@ -/* $Id: automap.c,v 1.18 2004-08-28 23:17:45 schaffner Exp $ */ +/* $Id: automap.c,v 1.19 2004-10-09 15:59:28 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -801,7 +801,7 @@ void create_name_canv() else sprintf(name_level_left, "Secret Level %i",-Current_level_num); - if (Current_mission_num == Builtin_mission_num && Current_level_num>0) //built-in mission + if (PLAYING_BUILTIN_MISSION && Current_level_num > 0) sprintf(name_level_right,"%s %d: ",system_name[(Current_level_num-1)/4],((Current_level_num-1)%4)+1); else strcpy(name_level_right, " "); diff --git a/main/cntrlcen.c b/main/cntrlcen.c index 294af1d2..81b264ef 100644 --- a/main/cntrlcen.c +++ b/main/cntrlcen.c @@ -1,4 +1,4 @@ -/* $Id: cntrlcen.c,v 1.16 2004-08-28 23:17:45 schaffner Exp $ */ +/* $Id: cntrlcen.c,v 1.17 2004-10-09 15:59:28 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -23,7 +23,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: cntrlcen.c,v 1.16 2004-08-28 23:17:45 schaffner Exp $"; +static char rcsid[] = "$Id: cntrlcen.c,v 1.17 2004-10-09 15:59:28 schaffner Exp $"; #endif #ifdef WINDOWS @@ -170,7 +170,7 @@ void do_countdown_frame() if (!is_D2_OEM && !is_MAC_SHARE && !is_SHAREWARE) // get countdown in OEM and SHAREWARE only { // On last level, we don't want a countdown. - if ((Current_mission_num == Builtin_mission_num) && (Current_level_num == Last_level)) + if (PLAYING_BUILTIN_MISSION && Current_level_num == Last_level) { if (!(Game_mode & GM_MULTI)) return; diff --git a/main/collide.c b/main/collide.c index 10203964..86ab16d3 100644 --- a/main/collide.c +++ b/main/collide.c @@ -1,4 +1,4 @@ -/* $Id: collide.c,v 1.13 2004-08-28 23:17:45 schaffner Exp $ */ +/* $Id: collide.c,v 1.14 2004-10-09 15:59:28 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -1371,9 +1371,9 @@ int apply_damage_to_robot(object *robot, fix damage, int killer_objnum) // Buddy invulnerable on level 24 so he can give you his important messages. Bah. // Also invulnerable if his cheat for firing weapons is in effect. if (Robot_info[robot->id].companion) { -// if ((Current_mission_num == Builtin_mission_num && Current_level_num == Last_level) || Buddy_dude_cheat) +// if ((PLAYING_BUILTIN_MISSION && Current_level_num == Last_level) || Buddy_dude_cheat) #ifdef NETWORK - if ((Current_mission_num == Builtin_mission_num && Current_level_num == Last_level) ) + if (PLAYING_BUILTIN_MISSION && Current_level_num == Last_level) return 0; #endif } @@ -1389,7 +1389,7 @@ int apply_damage_to_robot(object *robot, fix damage, int killer_objnum) // Do unspeakable hacks to make sure player doesn't die after killing boss. Or before, sort of. if (Robot_info[robot->id].boss_flag) #ifdef NETWORK - if ((Current_mission_num == Builtin_mission_num) && Current_level_num == Last_level) + if (PLAYING_BUILTIN_MISSION && Current_level_num == Last_level) #endif if (robot->shields < 0) { diff --git a/main/endlevel.c b/main/endlevel.c index 0092edde..02160186 100644 --- a/main/endlevel.c +++ b/main/endlevel.c @@ -1,4 +1,4 @@ -/* $Id: endlevel.c,v 1.22 2004-08-29 17:57:23 schaffner Exp $ */ +/* $Id: endlevel.c,v 1.23 2004-10-09 15:59:28 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -23,7 +23,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: endlevel.c,v 1.22 2004-08-29 17:57:23 schaffner Exp $"; +static char rcsid[] = "$Id: endlevel.c,v 1.23 2004-10-09 15:59:28 schaffner Exp $"; #endif //#define SLEW_ON 1 @@ -211,7 +211,7 @@ int start_endlevel_movie() int r; ubyte save_pal[768]; - //Assert(Current_mission_num == Builtin_mission_num); //only play movie for built-in mission + //Assert(PLAYING_BUILTIN_MISSION); //only play movie for built-in mission //Assert(N_MOVIES >= Last_level); //Assert(N_MOVIES_SECRET >= -Last_secret_level); @@ -313,7 +313,7 @@ void start_endlevel_sequence() Newdemo_state = ND_STATE_PAUSED; if (Newdemo_state == ND_STATE_PLAYBACK) { // don't do this if in playback mode - if (Current_mission_num == Builtin_mission_num) //only play movie for built-in mission + if (PLAYING_BUILTIN_MISSION) // only play movie for built-in mission start_endlevel_movie(); strcpy(last_palette_loaded,""); //force palette load next time return; @@ -341,11 +341,9 @@ void start_endlevel_sequence() } #endif - if (Current_mission_num == Builtin_mission_num) { - // only play movie for built-in mission + if (PLAYING_BUILTIN_MISSION) // only play movie for built-in mission if (!(Game_mode & GM_MULTI)) movie_played = start_endlevel_movie(); - } if (!(Game_mode & GM_MULTI) && (movie_played == MOVIE_NOT_PLAYED) && endlevel_data_loaded) { //don't have movie. Do rendered sequence, if available @@ -707,8 +705,7 @@ void do_endlevel_frame() if (ConsoleObject->segnum == transition_segnum) { - if ((Current_mission_num == Builtin_mission_num) && - (start_endlevel_movie() != MOVIE_NOT_PLAYED)) + if (PLAYING_BUILTIN_MISSION && start_endlevel_movie() != MOVIE_NOT_PLAYED) stop_endlevel_sequence(); else { int objnum; diff --git a/main/gamerend.c b/main/gamerend.c index b7b65956..cc5b2311 100644 --- a/main/gamerend.c +++ b/main/gamerend.c @@ -1,4 +1,4 @@ -/* $Id: gamerend.c,v 1.13 2003-10-12 09:38:48 btb Exp $ */ +/* $Id: gamerend.c,v 1.14 2004-10-09 15:59:28 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -23,7 +23,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: gamerend.c,v 1.13 2003-10-12 09:38:48 btb Exp $"; +static char rcsid[] = "$Id: gamerend.c,v 1.14 2004-10-09 15:59:28 schaffner Exp $"; #endif #ifdef WINDOWS @@ -288,7 +288,7 @@ void render_countdown_gauge() if (!is_D2_OEM && !is_MAC_SHARE && !is_SHAREWARE) // no countdown on registered only { // On last level, we don't want a countdown. - if ((Current_mission_num == Builtin_mission_num) && (Current_level_num == Last_level)) + if (PLAYING_BUILTIN_MISSION && Current_level_num == Last_level) { if (!(Game_mode & GM_MULTI)) return; diff --git a/main/gameseq.c b/main/gameseq.c index e8f511c0..3400e7ca 100644 --- a/main/gameseq.c +++ b/main/gameseq.c @@ -1,4 +1,4 @@ -/* $Id: gameseq.c,v 1.36 2004-08-28 23:17:45 schaffner Exp $ */ +/* $Id: gameseq.c,v 1.37 2004-10-09 15:59:28 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -24,7 +24,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -char gameseq_rcsid[] = "$Id: gameseq.c,v 1.36 2004-08-28 23:17:45 schaffner Exp $"; +char gameseq_rcsid[] = "$Id: gameseq.c,v 1.37 2004-10-09 15:59:28 schaffner Exp $"; #endif #ifdef WINDOWS @@ -163,9 +163,9 @@ char Current_level_name[LEVEL_NAME_LEN]; int Last_level, Last_secret_level; // Global variables describing the player -int N_players=1; // Number of players ( >1 means a net game, eh?) -int Player_num=0; // The player number who is on the console. -player Players[MAX_PLAYERS+4]; // Misc player info +int N_players=1; // Number of players ( >1 means a net game, eh?) +int Player_num=0; // The player number who is on the console. +player Players[MAX_PLAYERS+4]; // Misc player info obj_position Player_init[MAX_PLAYERS]; // Global variables telling what sort of game we have @@ -285,7 +285,7 @@ gameseq_init_network_players() } #endif #ifdef NETWORK - if (is_D2_OEM && (Game_mode & GM_MULTI) && Current_mission_num == Builtin_mission_num && Current_level_num==8) + if (is_D2_OEM && (Game_mode & GM_MULTI) && PLAYING_BUILTIN_MISSION && Current_level_num==8) { for (i=0;i-1) digi_stop_sound( printing_channel ); - if (Mission_list[Current_mission_num].descent_version == 1) + if (EMULATING_D1) d_free(bsp); return rval; @@ -1274,10 +1274,9 @@ int show_briefing_text(int screen_num) { char *message_ptr; - if (Mission_list[Current_mission_num].descent_version == 1) - message_ptr = get_briefing_message(Briefing_screens[screen_num].message_num); - else - message_ptr = get_briefing_message(screen_num); + message_ptr = get_briefing_message + (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num); + if (message_ptr==NULL) return (0); @@ -1297,11 +1296,11 @@ void DoBriefingColorStuff () Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54); Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7); - if (Mission_list[Current_mission_num].descent_version == 1) { - //green - Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0); - Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0); - //white + if (EMULATING_D1) { + //green + Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0); + Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0); + //white Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32); Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14); @@ -1341,7 +1340,7 @@ int show_briefing_screen( int screen_num, int allow_keys) return 0; } - if (Mission_list[Current_mission_num].descent_version == 1) { + if (EMULATING_D1) { int pcx_error; #if 1 grs_bitmap briefing_bm; @@ -1460,7 +1459,7 @@ void do_briefing_screens(char *filename,int level_num) key_flush(); - if (Mission_list[Current_mission_num].descent_version == 1) { + if (EMULATING_D1) { if (level_num == 1) { while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) { abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0); -- 2.39.2