View Issue Details

IDProjectCategoryView StatusLast Update
0002166FSSCPtablespublic2010-05-19 05:48
ReporterEchelon9 Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionsuspended 
Product Version3.6.12 RC1 
Summary0002166: Convert Intel_list[] (and thus Intel_info[]) to use SCP_vector
DescriptionIntel_list[] (and the associated Intel_info[]) are currently arrays of size MAX_INTEL_ENTRIES = 75.

This feature will convert them to use SCP_vector, removing any numerical limits on Intelligence entries.
Additional InformationIntel_info[] is made up of tech_list_entry structs. Intel_info is the primary list of intelligence entries read from the table file.

From Intel_info, the subset of tech_list_entry structs which have their flags set to IIF_IN_TECH_DATABASE or IIF_DEFAULT_IN_TECH_DATABASE, will be copied into Intel_list.

Intel_list is the actual list of visible entries shown.

---

Ship_list[] and Weapon_list[] operate in a similar way, pulling the subset of visible tech_list_entry structs of their type from [Ship|Weapon]_info array.
TagsNo tags attached.

Relationships

related to 0002158 resolvedEchelon9 Species.tbl has a limit of 30 entries 

Activities

2010-03-28 04:52

 

Intel_list-vector.diff (9,839 bytes)   
Index: code/mission/missioncampaign.cpp
===================================================================
--- code/mission/missioncampaign.cpp	(revision 6028)
+++ code/mission/missioncampaign.cpp	(working copy)
@@ -891,7 +891,7 @@
 	ubyte out;
 
 	// write the ship and weapon count
-	cfwrite_int(Intel_info_size, fp);
+	cfwrite_int((int)Intel_info.size(), fp);
 
 	// write all ship flags out
 	for (i=0; i<Num_ship_classes; i++) {
@@ -906,7 +906,7 @@
 	}	
 
 	// write all intel entry flags out
-	for (i=0; i<Intel_info_size; i++) {
+	for (i = 0; i < (int)Intel_info.size(); i++) {
 		out = (Intel_info[i].flags & IIF_IN_TECH_DATABASE) ? (ubyte)1 : (ubyte)0;
 		cfwrite_ubyte(out, fp);
 	}
@@ -1373,7 +1373,7 @@
 				Weapon_info[idx].wi_flags &= ~WIF_IN_TECH_DATABASE;
 			}
 
-			for (idx=0; idx<MAX_INTEL_ENTRIES; idx++) {
+			for (idx = 0; idx < (int)Intel_info.size(); idx++) {
 				Intel_info[idx].flags &= ~IIF_IN_TECH_DATABASE;
 			}
 		}
@@ -1412,7 +1412,7 @@
 		for (idx=0; idx<intel_count; idx++) {
 			in = cfread_ubyte(fp);
 
-			if (idx >= Intel_info_size)
+			if (idx >= (int)Intel_info.size())
 				continue;
 
 			if (in) {
Index: code/playerman/managepilot.cpp
===================================================================
--- code/playerman/managepilot.cpp	(revision 6028)
+++ code/playerman/managepilot.cpp	(working copy)
@@ -300,7 +300,7 @@
 	// write the ship and weapon count
 	cfwrite_int(Num_ship_classes, file);
 	cfwrite_int(Num_weapon_types, file);
-	cfwrite_int(Intel_info_size, file);
+	cfwrite_int((int)Intel_info.size(), file);
 
 	// write all ship flags out
 	for (idx=0; idx<Num_ship_classes; idx++) {
@@ -315,7 +315,7 @@
 	}	
 
 	// write all intel entry flags out
-	for (idx=0; idx<Intel_info_size; idx++) {
+	for (idx = 0; idx < (int)Intel_info.size(); idx++) {
 		out = (Intel_info[idx].flags & IIF_IN_TECH_DATABASE) ? (ubyte)1 : (ubyte)0;
 		cfwrite_ubyte(out, file);
 	}
Index: code/menuui/techmenu.cpp
===================================================================
--- code/menuui/techmenu.cpp	(revision 6028)
+++ code/menuui/techmenu.cpp	(working copy)
@@ -275,27 +275,15 @@
 static int Ship_list_size = 0;
 static tech_list_entry *Weapon_list = NULL;
 static int Weapon_list_size = 0;
-static tech_list_entry Intel_list[MAX_INTEL_ENTRIES];
-static int Intel_list_size = 0;
+static SCP_vector<tech_list_entry> Intel_list;
 static tech_list_entry *Current_list;								// points to currently valid display list
 static int Current_list_size = 0;
 
 // slider stuff
 static UI_SLIDER2 Tech_slider;
 
-//XSTR:OFF
-/*
-static char *Intel_anim_filenames[MAX_INTEL_ENTRIES] = {
-	"tech_tpilot.ani",
-	"tech_vasudan.ani",
-	"tech_shivan.ani",
-};
-*/
-//XSTR:ON
-
 // Intelligence master data structs (these get inited @ game startup from species.tbl)
-intel_data Intel_info[MAX_INTEL_ENTRIES];
-int Intel_info_size = 0;
+SCP_vector<intel_data> Intel_info;
 
 // some prototypes to make you happy
 int techroom_load_ani(anim **animpp, char *name);
@@ -339,7 +327,7 @@
 		}
 	}
 
-	for (i = 0; i < Intel_list_size; i++) {
+	for (i = 0; i < (int)Intel_list.size(); i++) {
 		if (Intel_list[i].animation.num_frames != 0) {
 			generic_anim_unload(&Intel_list[i].animation);
 		}
@@ -917,33 +905,35 @@
 			// load intel if necessary
 			if ( Intel_loaded == 0 ) {
 				// now populate the entry structs
-				Intel_list_size = 0;
 
-				for (i=0; i<Intel_info_size; i++) {
+				for (i = 0; i < (int)Intel_info.size(); i++) {
 					if (Techroom_show_all || (Intel_info[i].flags & IIF_IN_TECH_DATABASE) || (Intel_info[i].flags & IIF_DEFAULT_IN_TECH_DATABASE)) {
+						tech_list_entry	new_tech_list_entry;
+						
 						// leave option for no animation if string == "none"
 						if (!strcmp(Intel_info[i].anim_filename, "none")) {
-							Intel_list[Intel_list_size].has_anim = 0;
-							Intel_list[Intel_list_size].animation.num_frames = 0;
+							new_tech_list_entry.has_anim = 0;
+							new_tech_list_entry.animation.num_frames = 0;
 						} else {
 							// try and load as an animation
-							Intel_list[Intel_list_size].has_anim = 0;
-							Intel_list[Intel_list_size].bitmap = -1;
-							strncpy(Intel_list[Intel_list_size].tech_anim_filename, Intel_info[i].anim_filename, NAME_LENGTH - 1);
+							new_tech_list_entry.has_anim = 0;
+							new_tech_list_entry.bitmap = -1;
+							strncpy(new_tech_list_entry.tech_anim_filename, Intel_info[i].anim_filename, NAME_LENGTH - 1);
 						}
 
-						Intel_list[Intel_list_size].desc = Intel_info[i].desc;
-						Intel_list[Intel_list_size].index = i;
-						Intel_list[Intel_list_size].name = Intel_info[i].name;
-						Intel_list[Intel_list_size].model_num = -1;
-						Intel_list[Intel_list_size].textures_loaded = 0;
+						new_tech_list_entry.desc = Intel_info[i].desc;
+						new_tech_list_entry.index = i;
+						new_tech_list_entry.name = Intel_info[i].name;
+						new_tech_list_entry.model_num = -1;
+						new_tech_list_entry.textures_loaded = 0;
 
-						Intel_list_size++;
+						Intel_list.push_back(new_tech_list_entry);
 					}
 				}
 
 				// make sure that at least the default entry is cleared out if we didn't grab anything
-				if (Intel_info_size && !Intel_list_size) {
+				// Echelon9: This may well be redundant now that Intel_list uses SCP_vector<>
+				if ((int)Intel_info.size() && !(int)Intel_list.size()) {
 					Intel_list[0].index = -1;
 					Intel_list[0].desc = NULL;
 					Intel_list[0].name = NULL;
@@ -960,7 +950,7 @@
 			// index lookup on intel is a pretty pointless, but it keeps everything 
 			// consistent and doesn't really hurt anything
 			Current_list = Intel_list;
-			Current_list_size = Intel_list_size;
+			Current_list_size = (int)Intel_list.size();
 
 			font_height = gr_get_font_height();
 			max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
@@ -1129,34 +1119,29 @@
 	read_file_text("species.tbl", CF_TYPE_TABLES);
 	reset_parse();
 
-	Intel_info_size = 0;
 	while (optional_string("$Entry:")) {
-		Assert(Intel_info_size < MAX_INTEL_ENTRIES);
-		if (Intel_info_size >= MAX_INTEL_ENTRIES) {
-			mprintf(("TECHMENU: Too many intel entries!\n"));
-			break;
-		}
+		intel_data new_intel_data;
 
-		Intel_info[Intel_info_size].flags = IIF_DEFAULT_VALUE;
+		new_intel_data.flags = IIF_DEFAULT_VALUE;
 
 		required_string("$Name:");
-		stuff_string(Intel_info[Intel_info_size].name, F_NAME, NAME_LENGTH);
+		stuff_string(new_intel_data.name, F_NAME, NAME_LENGTH);
 
 		required_string("$Anim:");
-		stuff_string(Intel_info[Intel_info_size].anim_filename, F_NAME, NAME_LENGTH);
+		stuff_string(new_intel_data.anim_filename, F_NAME, NAME_LENGTH);
 
 		required_string("$AlwaysInTechRoom:");
 		stuff_int(&temp);
 		if (temp) {
 			// set default to align with what we read - Goober5000
-			Intel_info[Intel_info_size].flags |= IIF_IN_TECH_DATABASE;
-			Intel_info[Intel_info_size].flags |= IIF_DEFAULT_IN_TECH_DATABASE;
+			new_intel_data.flags |= IIF_IN_TECH_DATABASE;
+			new_intel_data.flags |= IIF_DEFAULT_IN_TECH_DATABASE;
 		}
 
 		required_string("$Description:");
-		stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, TECH_INTEL_DESC_LEN);
+		stuff_string(new_intel_data.desc, F_MULTITEXT, TECH_INTEL_DESC_LEN);
 
-		Intel_info_size++;
+		Intel_info.push_back(new_intel_data);
 	}
 
 	inited = 1;
@@ -1288,7 +1273,7 @@
 	Tech_slider.create(&Ui_window, Tech_slider_coords[gr_screen.res][SHIP_X_COORD], Tech_slider_coords[gr_screen.res][SHIP_Y_COORD], Tech_slider_coords[gr_screen.res][SHIP_W_COORD], Tech_slider_coords[gr_screen.res][SHIP_H_COORD], Num_ship_classes, Tech_slider_filename[gr_screen.res], &tech_scroll_list_up, &tech_scroll_list_down, &tech_ship_scroll_capture);
 
 	// zero intel anim/bitmap stuff
-	for(idx=0; idx<MAX_INTEL_ENTRIES; idx++){
+	for(idx = 0; idx < (int)Intel_list.size(); idx++){
 		Intel_list[idx].animation.num_frames = 0;
 		Intel_list[idx].bitmap = -1;
 	}
@@ -1337,7 +1322,7 @@
 	Weapon_list_size = 0;
 	Weapons_loaded = 0;
 
-	for (i = 0; i < Intel_list_size; i++) {
+	for (i = 0; i < (int)Intel_list.size(); i++) {
 		if (Intel_list[i].animation.num_frames != 0) {
 			generic_anim_unload(&Intel_list[i].animation);
 		}
@@ -1348,7 +1333,6 @@
 		}
 	}
 
-	Intel_list_size = 0;
 	Intel_loaded = 0;
 }
 
@@ -1581,7 +1565,7 @@
 	if (!name)
 		return -1;
 
-	for (i=0; i<Intel_info_size; i++)
+	for (i = 0; i < (int)Intel_info.size(); i++)
 		if (!stricmp(name, Intel_info[i].name))
 			return i;
 
@@ -1617,7 +1601,7 @@
 	}
 
 	// intelligence
-	for (i=0; i<Intel_info_size; i++)
+	for (i = 0; i < (int)Intel_info.size(); i++)
 	{
 		if (Intel_info[i].flags & IIF_DEFAULT_IN_TECH_DATABASE)
 			Intel_info[i].flags |= IIF_IN_TECH_DATABASE;
Index: code/menuui/techmenu.h
===================================================================
--- code/menuui/techmenu.h	(revision 6028)
+++ code/menuui/techmenu.h	(working copy)
@@ -29,10 +29,8 @@
 #define IIF_IN_TECH_DATABASE			(1 << 0)	// in tech database? - Goober5000
 #define IIF_DEFAULT_IN_TECH_DATABASE	(1 << 1)	// in tech database by default? - Goober5000
 
-extern intel_data Intel_info[MAX_INTEL_ENTRIES];
-extern int Intel_info_size;
+extern SCP_vector<intel_data> Intel_info;
 
-
 // function prototypes
 void techroom_init();
 void techroom_close();
Index: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp	(revision 6028)
+++ code/parse/sexp.cpp	(working copy)
@@ -2458,12 +2458,12 @@
 				if ( type2 != SEXP_ATOM_STRING )
 					return SEXP_CHECK_TYPE_MISMATCH;
 
-				for (i = 0; i < Intel_info_size; i++ ) {
+				for (i = 0; i < (int)Intel_info.size(); i++ ) {
 					if ( !stricmp(CTEXT(node), Intel_info[i].name) )
 						break;
 				}
 
-				if ( i == Intel_info_size )
+				if ( i == (int)Intel_info.size() )
 					return SEXP_CHECK_INVALID_INTEL_NAME;
 				
 				break;
Intel_list-vector.diff (9,839 bytes)   

Echelon9

2010-03-28 05:03

developer   ~0011839

Last edited: 2010-03-28 05:04

Patch proposed -- although it currently will not compile with problems when Current_list array is set to Intel_list vector at techmenu.cpp:952.

Current_list is also used by Ship_intel and Weapon_intel, both of which I have not changed to be vectors yet.

Goober5000

2010-05-19 05:48

administrator   ~0011986

Intel_list does not affect Intel_info; they are two different arrays. Also, I'm closing this because 1) it's a feature request, and 2) it's not as long-term as you think.

Issue History

Date Modified Username Field Change
2010-03-28 04:47 Echelon9 New Issue
2010-03-28 04:47 Echelon9 Status new => assigned
2010-03-28 04:47 Echelon9 Assigned To => Echelon9
2010-03-28 04:52 Echelon9 File Added: Intel_list-vector.diff
2010-03-28 04:52 Echelon9 Relationship added related to 0002158
2010-03-28 04:53 Echelon9 Description Updated
2010-03-28 04:59 Echelon9 Additional Information Updated
2010-03-28 05:01 Echelon9 Additional Information Updated
2010-03-28 05:03 Echelon9 Note Added: 0011839
2010-03-28 05:04 Echelon9 Note Edited: 0011839
2010-05-19 05:48 Goober5000 Note Added: 0011986
2010-05-19 05:48 Goober5000 Assigned To Echelon9 =>
2010-05-19 05:48 Goober5000 Status assigned => closed
2010-05-19 05:48 Goober5000 Resolution open => suspended