View Issue Details

IDProjectCategoryView StatusLast Update
0002608FSSCPcutscenespublic2012-02-20 15:36
ReporterEli2 Assigned ToEli2  
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product VersionAntipodes 8 
Summary0002608: Cutscene Always Viewable
Descriptionhttp://www.hard-light.net/forums/index.php?topic=79827.0
mjn.mixael:
I'm interested in a flag for the cutscene.tbl that makes a cutscene always viewable in the techroom regardless of whether or not it's been played in the campaign.
TagsNo tags attached.

Activities

Eli2

2012-02-19 22:53

developer  

0001-Cutscene-always-viewable.svn.patch (7,254 bytes)   
Index: code/cutscene/cutscenes.cpp
===================================================================
--- code/cutscene/cutscenes.cpp
+++ code/cutscene/cutscenes.cpp
@@ -35,11 +35,9 @@ char *Cutscene_mask_name[GR_NUM_RESOLUTIONS] = {
 	"2_ViewFootage-m"
 };
 
-int Cutscenes_viewable;
 int Description_index;
 SCP_vector<cutscene_info> Cutscenes;
 
-//extern int All_movies_enabled;		//	If set, all movies may be viewed.  Keyed off cheat code.
 void cutscene_close()
 {
 	for(SCP_vector<cutscene_info>::iterator cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut)
@@ -72,6 +70,8 @@ void cutscene_init()
 	skip_to_string("#Cutscenes");
 	ignore_white_space();
 
+	bool isFirstCutscene = true;
+
 	while ( required_string_either("#End", "$Filename:") ) 
     {
         memset(&cutinfo, 0, sizeof(cutscene_info));
@@ -91,13 +91,22 @@ void cutscene_init()
 		required_string("$cd:");
 		stuff_int( &cutinfo.cd );
 
+		if (isFirstCutscene) {
+			isFirstCutscene = false;
+			//The original code assumes the first movie is the intro, so always viewable
+			cutinfo.viewable = true;
+		}
+
+		if (optional_string("$Always Viewable:")) {
+			stuff_boolean(&cutinfo.viewable);
+		}
+
+
         Cutscenes.push_back(cutinfo);
 	}
 
 	required_string("#End");
 
-	Cutscenes_viewable = INTRO_CUTSCENE_FLAG;
-
 	// close localization
 	lcl_ext_close();
 }
@@ -140,7 +149,7 @@ void cutscene_mark_viewable(char *filename)
 
 		// see if the stripped filename matches the cutscene filename
 		if ( strstr(cut_file, file) != NULL ) {
-			Cutscenes_viewable |= (1<<i);
+			cut->viewable = true;
 			return;
 		}
 		i++;
@@ -473,22 +482,14 @@ void cutscenes_screen_init()
 	Scroll_offset = Selected_line = 0;
 	Description_index = -1;
 
-	// when doing a debug version, just put all of the movie files here.
-#ifndef NDEBUG
-	//Cutscenes_viewable = 0xffffffff;			// makes all cutscenes viewble.
-#endif
-
-//  	if (All_movies_enabled)
-//  		Cutscenes_viewable = 0xffffffff;		//	Cheat code enables all movies.
-
     Cutscene_list.clear();
 	
-	size_t size = Cutscenes.size();
-	for (size_t j=0;j < size;j++) {
-		if ( Cutscenes_viewable & (1<<j) ) {
-            Cutscene_list.push_back((int)j);
+    int u = 0;
+    for (SCP_vector<cutscene_info>::iterator cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut, u++) {
+		if ( (*cut).viewable ) {
+			Cutscene_list.push_back(u);
 		}
-	}
+    }
 }
 
 void cutscenes_screen_close()
Index: code/cutscene/cutscenes.h
===================================================================
--- code/cutscene/cutscenes.h
+++ code/cutscene/cutscenes.h
@@ -5,9 +5,7 @@
  * or otherwise commercially exploit the source or things you created based on the 
  * source.
  *
-*/ 
-
-
+ */
 
 #ifndef _FREESPACE_CUTSCENES_SCREEN_HEADER_FILE
 #define _FREESPACE_CUTSCENES_SCREEN_HEADER_FILE
@@ -15,25 +13,24 @@
 #include "globalincs/globals.h"
 #include "globalincs/pstypes.h"
 
-// this cutscene is always available.
-#define INTRO_CUTSCENE_FLAG		(1<<0)
+typedef struct cutscene_info {
+	cutscene_info() :
+		viewable(false)
+	{}
 
-typedef struct cutscene_info
-{
-	char		filename[MAX_FILENAME_LEN];
-	char		name[NAME_LENGTH];
-	char		*description;
+	char	filename[MAX_FILENAME_LEN];
+	char	name[NAME_LENGTH];
+	char	*description;
 	int		cd;
+	bool	viewable;
 } cutscene_info;
 
 extern SCP_vector<cutscene_info> Cutscenes;
-extern int Cutscenes_viewable;
 
 // initializa table data
 void cutscene_init();
 int cutscene_get_cd_num(char *filename);
 
-
 void cutscenes_screen_init();
 void cutscenes_screen_close();
 void cutscenes_screen_do_frame();
Index: code/pilotfile/csg.cpp
===================================================================
--- code/pilotfile/csg.cpp
+++ code/pilotfile/csg.cpp
@@ -38,9 +38,6 @@ void pilotfile::csg_read_flags()
 {
 	// tips?
 	p->tips = (int)cfread_ubyte(cfp);
-
-	// available cutscenes
-	Cutscenes_viewable = cfread_int(cfp);
 }
 
 void pilotfile::csg_write_flags()
@@ -50,9 +47,6 @@ void pilotfile::csg_write_flags()
 	// tips
 	cfwrite_ubyte((ubyte)p->tips, cfp);
 
-	// cutscenes
-	cfwrite_int(Cutscenes_viewable, cfp);
-
 	endSection();
 }
 
@@ -1148,6 +1142,35 @@ void pilotfile::csg_write_controls()
 	endSection();
 }
 
+void pilotfile::csg_read_cutscenes() {
+	size_t list_size = cfread_uint(cfp);
+
+	for(size_t i = 0; i < list_size; i++) {
+		char tempFilename[MAX_FILENAME_LEN];
+
+		cfread_string_len(tempFilename, MAX_FILENAME_LEN, cfp);
+		cutscene_mark_viewable(tempFilename);
+	}
+}
+
+void pilotfile::csg_write_cutscenes() {
+	startSection(Section::Cutscenes);
+
+	size_t viewableScenes = 0;
+	for(SCP_vector<cutscene_info>::iterator cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) {
+		if(cut->viewable)
+			viewableScenes ++;
+	}
+	cfwrite_uint(viewableScenes, cfp);
+
+	for(SCP_vector<cutscene_info>::iterator cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) {
+		if(cut->viewable)
+			cfwrite_string_len(cut->filename, cfp);
+	}
+
+	endSection();
+}
+
 void pilotfile::csg_reset_data()
 {
 	int idx;
@@ -1346,6 +1369,11 @@ bool pilotfile::load_savefile(const char *campaign)
 					csg_read_controls();
 					break;
 
+				case Section::Cutscenes:
+					mprintf(("CSG => Parsing:  Cutscenes...\n"));
+					csg_read_cutscenes();
+					break;
+
 				default:
 					mprintf(("CSG => Skipping unknown section 0x%04x!\n", section_id));
 					break;
@@ -1449,6 +1477,8 @@ bool pilotfile::save_savefile()
 	csg_write_settings();
 	mprintf(("CSG => Saving:  Controls...\n"));
 	csg_write_controls();
+	mprintf(("CSG => Saving:  Cutscenes...\n"));
+	csg_write_cutscenes();
 
 	// Done!
 	mprintf(("CSG => Saving complete!\n"));
Index: code/pilotfile/pilotfile.h
===================================================================
--- code/pilotfile/pilotfile.h
+++ code/pilotfile/pilotfile.h
@@ -119,7 +119,8 @@ class pilotfile {
 				Settings		= 0x0010,
 				RedAlert		= 0x0011,
 				Variables		= 0x0012,
-				Missions		= 0x0013
+				Missions		= 0x0013,
+				Cutscenes		= 0x0014
 			};
 		};
 
@@ -173,6 +174,7 @@ class pilotfile {
 		void csg_read_variables();
 		void csg_read_settings();
 		void csg_read_controls();
+		void csg_read_cutscenes();
 
 		void csg_write_flags();
 		void csg_write_info();
@@ -185,6 +187,7 @@ class pilotfile {
 		void csg_write_variables();
 		void csg_write_settings();
 		void csg_write_controls();
+		void csg_write_cutscenes();
 };
 
 extern pilotfile Pilot;
Index: code/playerman/managepilot.cpp
===================================================================
--- code/playerman/managepilot.cpp
+++ code/playerman/managepilot.cpp
@@ -141,7 +141,7 @@ void init_new_pilot(player *p, int reset)
 
 	// reset the cutscenes which can be viewed
 	if ( reset ){
-		Cutscenes_viewable = INTRO_CUTSCENE_FLAG;
+		cutscene_init();
 	}
 
 	pilot_set_start_campaign(p);
@@ -307,9 +307,6 @@ int pilot_verify_overwrite()
 	return popup(PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON | PF_TITLE_RED | PF_TITLE_BIG, 2, XSTR( "&No", 47), XSTR( "&Yes", 48), XSTR( "Warning\nA duplicate pilot exists\nOverwrite?", 49));
 }
 
-extern int Skip_packfile_search;  // located in CFileList.cpp
-
-
 // load up the list of pilot image filenames (do this at game startup as well as barracks startup)
 void pilot_load_pic_list()
 {
-- 
1.7.5.4

MjnMixael

2012-02-19 23:08

manager   ~0013334

I tested this and it works as expected. Nice work, thanks.

Eli2

2012-02-20 15:35

developer   ~0013337

Committed in revision 8527

Issue History

Date Modified Username Field Change
2012-02-19 22:53 Eli2 New Issue
2012-02-19 22:53 Eli2 Status new => assigned
2012-02-19 22:53 Eli2 Assigned To => Eli2
2012-02-19 22:53 Eli2 File Added: 0001-Cutscene-always-viewable.svn.patch
2012-02-19 22:53 Eli2 Status assigned => feedback
2012-02-19 22:53 Eli2 Status feedback => code review
2012-02-19 23:08 MjnMixael Note Added: 0013334
2012-02-19 23:16 Eli2 File Added: 0001-Proper-Secion-indices.svn.patch
2012-02-19 23:16 Eli2 File Deleted: 0001-Proper-Secion-indices.svn.patch
2012-02-20 15:35 Eli2 Note Added: 0013337
2012-02-20 15:36 Eli2 Status code review => resolved
2012-02-20 15:36 Eli2 Resolution open => fixed