View Issue Details

IDProjectCategoryView StatusLast Update
0002815FSSCPPilot datapublic2013-04-06 03:23
ReporterFUBAR-BDHR Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.19 
Summary0002815: Bug with changing squadrons in barracks
DescriptionIn single player if you try to change squadrons you get the message that you can't change squads while in single player which is fine. Since the new pilot code doesn't distinguish between single an multi pilots you can get around this by simply clicking the multi tab and then changing the squad. Switching back to single and even exiting and relaunching the game still show the changed squad.

If this actually will cause and game breaking issues I have no clue but it seems there needs to be a separation of single and multi pilot squad data to prevent this sort of thing.
Steps To ReproduceCreate new pilot (probably not necessary but why not)
Launch game in single player mode
Go to barracks
Attempt to change squad you should get a message about not being allowed to change in single player
Click on the multi option
Change squad.
Click back on single
Note the squad remains as the changed one.
Exit game, go back in, still changed.
TagsNo tags attached.

Relationships

related to 0002832 resolvedniffiwan pilotfile conversion doesn't export correct PLR/CSG versions 
related to 0002838 resolvedniffiwan Squad logos not working 

Activities

niffiwan

2013-04-01 07:41

developer   ~0014866

I've going to try solving this by storing the multi squad & image in the .plr, and the single player squad & image in the .csg, and then adjusting all the relevant calls that deal with these to use one of these two locations as appropriate.

niffiwan

2013-04-04 09:45

developer   ~0014886

Please test this patch. In the barracks, pilots should have independent squad images for single & multi player. The single player image relies on missions to set it. It'll be unique per campaign (i.e. csg savefile). If a campaign file is missing, the image should be blank. Pilot conversion will make the image from the old pilot the multiplayer image and leave the single player image blank.

FUBAR-BDHR

2013-04-04 20:18

developer   ~0014889

Haven't had a chance to test it yet but I have a feeling that a blank image is going to cause issues. Those logos get applied to the ships in retail. What happens if it's blank and you play a single player non-campaign mission?

MjnMixael

2013-04-04 22:49

manager   ~0014890

Last edited: 2013-04-04 23:10

No logo, mostly likely. Ship insignia are not required in every single mission ever. But how's about we test it first instead of asking someone to go code a bunch of stuff on a hunch?

EDIT: Tested. The single vs multi data seems to work as expected. I can change the multi logo, but not the single. The single started out blank (which, btw, didn't crash any missions or anything.. just played them without insignia on my ship.. or the mission applied the insignia designated by the FREDer.), but was accurately changed by the campaign I chose each time. The proper insignia were showing up on the ships in-mission correctly as well.

niffiwan

2013-04-04 23:11

developer   ~0014891

Also, the blanking of the squad image only occurs for the display in the barracks. Once you exit the barracks, FSO will whinge at you for not having a valid campaign, so I don't think that such a pilot will be able to play a mission.

I believe all other cases will act the same as current behaviour, i.e. if no campaign missions have been played to set a single player squad image, then it'll work as MjnMixael described. If it causes issues, then I think it's a separate bug :)

(I didn't actually test/look for squad images on ships in missions, I didn't know/remember they were there :D)

FUBAR-BDHR

2013-04-05 02:33

developer   ~0014893

Alright did some comparison between 3.6.18 and latest with this patch with retail FS2.

3.6.18 ships have a squad at retail FS2 campaign start. This patch no squad on ships.
3.6.18 ships in single player have a squad if no campaign has been played. This patch no squad on single player missions even after playing the training missions and first mission of retail campaign.

Also campaigns (.fc2 files) are not a requirement for playing FS2. TC's can release with only single missions and no campaign. This is also actually quite common to not have a .fc2 file during development as it is a pain to use the cheat every-time you want to test a mission. Diaspora had no fc2 file for most of it's development. Default core only install of TBP has no campaigns or missions at all they are contained in separate vp files (although EMWdemo and Raider wars VPs are included in the installer).

So in summary this is a change from retail behavior and there should be a default non-blank squad in for both campaigns and single player missions. I believe retail just picked one at random since in testing I received the hammerheads logo one time and the V logo another.

FUBAR-BDHR

2013-04-05 02:49

developer   ~0014894

Last edited: 2013-04-05 02:56

After some more testing I don't think this is working at all. Even in SM1-01 which has the squad reassign in the mission there is no squad showing on the ship. Going to test without this patch and see if it was broke before it.

It doesn't work without this patch either so looks like a separate bug.

niffiwan

2013-04-05 04:02

developer   ~0014895

I think you've found a retail bug with the hammerheads logo (I hit this too and it wasted at least an hour of my testing!) In retail, SM1-01 sets the squad logo to hammer.pcx. However, the real filename is hammer1.pcx! Try testing with the mediavps instead.

niffiwan

2013-04-05 05:32

developer   ~0014897

per discussions on IRC, I'm going to update the patch to:
1) assign a single logo in the same function that assigns the random multi logo
2) do the same in pilot conversions (except that logo won't be random)
3) if no CSG can be loaded, assign the multi logo to the single one

That should cover all the cases that can currently result in a blank single player logo.

niffiwan

2013-04-05 09:47

developer   ~0014898

Last edited: 2013-04-06 01:43

Try this one. Should have fixed everything in my previous comment except the conversion process, which is currently borked due to 2832 (unless you hexedit the csg/plr files yourself to set the correct version)

edit: and updated again, with a minor tweak and a fix to have pilots created at the initial selection screen get a valid single squad image
(why is there a separate pilot selection screen anyway? Why not just punt players straight to the barracks?)

niffiwan

2013-04-06 01:42

developer  

mantis2815-svn.patch (20,908 bytes)   
Index: code/pilotfile/csg.cpp
===================================================================
--- code/pilotfile/csg.cpp	(revision 9621)
+++ code/pilotfile/csg.cpp	(working copy)
@@ -33,7 +33,8 @@
 //
 //   0 - initial version
 //   1 - re-add recent missions
-static const ubyte CSG_VERSION = 1;
+//   2 - separate single/multi squad name & pic
+static const ubyte CSG_VERSION = 2;
 
 
 void pilotfile::csg_read_flags()
@@ -167,6 +168,12 @@
 		}
 	}
 
+	if (csg_ver >= 2) {
+		// single/campaign squad name & image
+		cfread_string_len(p->s_squad_name, NAME_LENGTH, cfp);
+		cfread_string_len(p->s_squad_filename, MAX_FILENAME_LEN, cfp);
+	}
+
 	// if anything we need/use was missing then it should be considered fatal
 	if (m_data_invalid) {
 		throw "Invalid data for CSG!";
@@ -231,6 +238,10 @@
 		cfwrite_ubyte(Campaign.weapons_allowed[idx], cfp);
 	}
 
+	// single/campaign squad name & image
+	cfwrite_string_len(p->s_squad_name, cfp);
+	cfwrite_string_len(p->s_squad_filename, cfp);
+
 	endSection();
 }
 
@@ -1337,8 +1348,8 @@
 		return false;
 	}
 
-	// version, should be able to just ignore it
-	ubyte csg_ver = cfread_ubyte(cfp);
+	// version, now used
+	csg_ver = cfread_ubyte(cfp);
 
 	mprintf(("CSG => Loading '%s' with version %d...\n", filename.c_str(), (int)csg_ver));
 
@@ -1449,6 +1460,12 @@
 		}
 	}
 
+	// if the campaign (for whatever reason) doesn't have a squad image, use the multi one
+	if (p->s_squad_filename[0] == '\0') {
+		strcpy_s(p->s_squad_filename, p->m_squad_filename);
+	}
+	player_set_squad_bitmap(p, p->s_squad_filename, false);
+
 	mprintf(("CSG => Loading complete!\n"));
 
 	// cleanup and return
@@ -1505,7 +1522,7 @@
 	cfwrite_int(CSG_FILE_ID, cfp);
 	cfwrite_ubyte(CSG_VERSION, cfp);
 
-	mprintf(("CSG => Saving '%s' with version %d...\n", filename.c_str(), (int)CSG_VERSION));
+	mprintf(("CSG => Saving '%s' with version %d...\n", filename.c_str(), (int)csg_ver));
 
 	// flags and info sections go first
 	mprintf(("CSG => Saving:  Flags...\n"));
Index: code/pilotfile/csg_convert.cpp
===================================================================
--- code/pilotfile/csg_convert.cpp	(revision 9621)
+++ code/pilotfile/csg_convert.cpp	(working copy)
@@ -757,6 +757,10 @@
 		cfwrite_ubyte(visible, cfp);
 	}
 
+	// single/campaign squad name & image, make it the same as multi
+	cfwrite_string_len(plr->squad_name, cfp);
+	cfwrite_string_len(plr->squad_filename, cfp);
+
 	endSection();
 }
 
Index: code/pilotfile/pilotfile.h
===================================================================
--- code/pilotfile/pilotfile.h	(revision 9621)
+++ code/pilotfile/pilotfile.h	(working copy)
@@ -42,6 +42,7 @@
 		player *p;
 
 		int version;
+		ubyte csg_ver;
 
 		// some sections are required before others...
 		bool m_have_flags;
Index: code/pilotfile/plr.cpp
===================================================================
--- code/pilotfile/plr.cpp	(revision 9621)
+++ code/pilotfile/plr.cpp	(working copy)
@@ -89,11 +89,11 @@
 	// pilot image
 	cfread_string_len(p->image_filename, MAX_FILENAME_LEN, cfp);
 
-	// squad name
-	cfread_string_len(p->squad_name, NAME_LENGTH, cfp);
+	// multi squad name
+	cfread_string_len(p->m_squad_name, NAME_LENGTH, cfp);
 
 	// squad image
-	cfread_string_len(p->squad_filename, MAX_FILENAME_LEN, cfp);
+	cfread_string_len(p->m_squad_filename, MAX_FILENAME_LEN, cfp);
 
 	// active campaign
 	cfread_string_len(p->current_campaign, MAX_FILENAME_LEN, cfp);
@@ -106,11 +106,11 @@
 	// pilot image
 	cfwrite_string_len(p->image_filename, cfp);
 
-	// squad name
-	cfwrite_string_len(p->squad_name, cfp);
+	// multi squad name
+	cfwrite_string_len(p->m_squad_name, cfp);
 
 	// squad image
-	cfwrite_string_len(p->squad_filename, cfp);
+	cfwrite_string_len(p->m_squad_filename, cfp);
 
 	// active campaign
 	cfwrite_string_len(p->current_campaign, cfp);
@@ -915,7 +915,7 @@
 	// restore the truncated callsign into Player structure
 	pilot_set_short_callsign(p, SHORT_CALLSIGN_PIXEL_W);
 
-	player_set_squad_bitmap(p, p->squad_filename);
+	player_set_squad_bitmap(p, p->m_squad_filename, true);
 
 	hud_squadmsg_save_keys();
 
Index: code/network/multimsgs.cpp
===================================================================
--- code/network/multimsgs.cpp	(revision 9621)
+++ code/network/multimsgs.cpp	(working copy)
@@ -1043,7 +1043,7 @@
 	ADD_INT(Net_players[new_player_num].flags);
 	ADD_STRING(Net_players[new_player_num].m_player->callsign);
 	ADD_STRING(Net_players[new_player_num].m_player->image_filename);
-	ADD_STRING(Net_players[new_player_num].m_player->squad_filename);
+	ADD_STRING(Net_players[new_player_num].m_player->m_squad_filename);
 	ADD_STRING(Net_players[new_player_num].p_info.pxo_squad_name);
 
 	val = (ubyte)Net_players[new_player_num].p_info.team;
@@ -1122,7 +1122,7 @@
 		}
 		// copy his pilot squad filename
 		Net_players[new_player_num].m_player->insignia_texture = -1;
-		player_set_squad_bitmap(Net_players[new_player_num].m_player, new_player_squad);				
+		player_set_squad_bitmap(Net_players[new_player_num].m_player, new_player_squad, true);
 
 		// copy in his pxo squad name
 		strcpy_s(Net_players[new_player_num].p_info.pxo_squad_name, new_player_pxo_squad);
@@ -1236,7 +1236,7 @@
 		ADD_STRING(Net_players[i].m_player->image_filename);
 
 		// add his squad filename
-		ADD_STRING(Net_players[i].m_player->squad_filename);
+		ADD_STRING(Net_players[i].m_player->m_squad_filename);
 
 		// add his PXO squad name
 		ADD_STRING(Net_players[i].p_info.pxo_squad_name);
@@ -1330,7 +1330,7 @@
 		
 		// copy his pilot squad filename
 		Net_players[player_num].m_player->insignia_texture = -1;
-		player_set_squad_bitmap(Net_players[player_num].m_player, squad_name);
+		player_set_squad_bitmap(Net_players[player_num].m_player, squad_name, true);
 
 		// copy his pxo squad name
 		strcpy_s(Net_players[player_num].p_info.pxo_squad_name, pxo_squad_name);
Index: code/network/multi_pinfo.cpp
===================================================================
--- code/network/multi_pinfo.cpp	(revision 9621)
+++ code/network/multi_pinfo.cpp	(working copy)
@@ -517,11 +517,11 @@
 		gr_set_color_fast(&Color_normal);		
 
 		// if there is no image
-		if(strlen(p->squad_filename) <= 0){
+		if(strlen(p->m_squad_filename) <= 0){
 			strcpy_s(place_text,XSTR("No/Invalid Image", 1053));
 		} 
 		// if the image is xferring
-		else if(multi_xfer_lookup(p->squad_filename)){
+		else if(multi_xfer_lookup(p->m_squad_filename)){
 			strcpy_s(place_text,XSTR("Image Transferring", 691));
 		}
 		// if we're not accepting images
@@ -801,8 +801,8 @@
 		strcpy_s(Mp_pilot.filename, np->m_player->image_filename);
 		Mp_pilot.bitmap = bm_load_duplicate(Mp_pilot.filename);
 	}
-	if(np->m_player->squad_filename[0] != '\0'){
-		strcpy_s(Mp_squad.filename, np->m_player->squad_filename);
+	if(np->m_player->m_squad_filename[0] != '\0'){
+		strcpy_s(Mp_squad.filename, np->m_player->m_squad_filename);
 		Mp_squad.bitmap = bm_load_duplicate(Mp_squad.filename);
 	}
 
Index: code/network/multiui.cpp
===================================================================
--- code/network/multiui.cpp	(revision 9621)
+++ code/network/multiui.cpp	(working copy)
@@ -1898,8 +1898,8 @@
 	if(Player->image_filename[0] != '\0'){
 		strcpy_s(Multi_join_request.image_filename, Player->image_filename);
 	}	
-	if(Player->squad_filename[0] != '\0'){
-		strcpy_s(Multi_join_request.squad_filename, Player->squad_filename);
+	if(Player->m_squad_filename[0] != '\0'){
+		strcpy_s(Multi_join_request.squad_filename, Player->m_squad_filename);
 	}
 
 	// tracker id (if any)
Index: code/network/multiutil.cpp
===================================================================
--- code/network/multiutil.cpp	(revision 9621)
+++ code/network/multiutil.cpp	(working copy)
@@ -2461,7 +2461,7 @@
 
 		// copy his pilot squad filename
 		Net_players[net_player_num].m_player->insignia_texture = -1;
-		player_set_squad_bitmap(Net_players[net_player_num].m_player, jr->squad_filename);		
+		player_set_squad_bitmap(Net_players[net_player_num].m_player, jr->squad_filename, true);
 
 		// clear his multi_data info
 		multi_data_handle_join(net_player_num);
@@ -2507,7 +2507,7 @@
 
 		// copy his pilot squad filename		
 		Net_players[net_player_num].m_player->insignia_texture = -1;
-		player_set_squad_bitmap(Net_players[net_player_num].m_player, jr->squad_filename);				
+		player_set_squad_bitmap(Net_players[net_player_num].m_player, jr->squad_filename, true);
 
 		// clear his multi_data info
 		multi_data_handle_join(net_player_num);
Index: code/network/multi_data.cpp
===================================================================
--- code/network/multi_data.cpp	(revision 9621)
+++ code/network/multi_data.cpp	(working copy)
@@ -286,8 +286,8 @@
 
 	// verify that my pilot pic is valid
 	ok_to_send = 1;
-	if(strlen(Net_player->m_player->squad_filename)){
-		bmap = bm_load(Net_player->m_player->squad_filename);
+	if(strlen(Net_player->m_player->m_squad_filename)){
+		bmap = bm_load(Net_player->m_player->m_squad_filename);
 		if(bmap == -1){			
 			ok_to_send = 0;
 		}
@@ -312,19 +312,19 @@
 	}
 
 	if(ok_to_send){
-		with_ext = cf_add_ext(Net_player->m_player->squad_filename, NOX(".pcx"));
+		with_ext = cf_add_ext(Net_player->m_player->m_squad_filename, NOX(".pcx"));
 		if(with_ext != NULL){
-			strcpy_s(Net_player->m_player->squad_filename,with_ext);
+			strcpy_s(Net_player->m_player->m_squad_filename,with_ext);
 		}
 
 		// host should put his own pic file in the list now
-		if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && !(Game_mode & GM_STANDALONE_SERVER) && (Net_player->m_player->squad_filename[0] != '\0')){
-			multi_data_add_new(Net_player->m_player->squad_filename, MY_NET_PLAYER_NUM);
+		if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && !(Game_mode & GM_STANDALONE_SERVER) && (Net_player->m_player->m_squad_filename[0] != '\0')){
+			multi_data_add_new(Net_player->m_player->m_squad_filename, MY_NET_PLAYER_NUM);
 		}
 		// otherwise clients should just queue up a send
 		else {
 			// add a file extension if necessary			
-			multi_xfer_send_file(Net_player->reliable_socket, Net_player->m_player->squad_filename, CF_TYPE_ANY, MULTI_XFER_FLAG_AUTODESTROY | MULTI_XFER_FLAG_QUEUE);
+			multi_xfer_send_file(Net_player->reliable_socket, Net_player->m_player->m_squad_filename, CF_TYPE_ANY, MULTI_XFER_FLAG_AUTODESTROY | MULTI_XFER_FLAG_QUEUE);
 		}		
 	}
 }
@@ -413,8 +413,8 @@
 
 	// go through all connected and try to reload their images if necessary
 	for(idx=0; idx<MAX_PLAYERS; idx++){
-		if(MULTI_CONNECTED(Net_players[idx]) && strlen(Net_players[idx].m_player->squad_filename) && (Net_players[idx].m_player->insignia_texture == -1)){
-			Net_players[idx].m_player->insignia_texture = bm_load_duplicate(Net_players[idx].m_player->squad_filename);
+		if(MULTI_CONNECTED(Net_players[idx]) && strlen(Net_players[idx].m_player->m_squad_filename) && (Net_players[idx].m_player->insignia_texture == -1)){
+			Net_players[idx].m_player->insignia_texture = bm_load_duplicate(Net_players[idx].m_player->m_squad_filename);
 
 			// if the bitmap loaded properly, lock it as a transparent texture
 			if(Net_players[idx].m_player->insignia_texture != -1){
Index: code/menuui/barracks.cpp
===================================================================
--- code/menuui/barracks.cpp	(revision 9621)
+++ code/menuui/barracks.cpp	(working copy)
@@ -525,23 +525,31 @@
 		Cur_pilot->callsign[0] = 0;  // this indicates no pilot active
 		return -1;
 	} else {
-		Pilot.load_savefile(Cur_pilot->current_campaign);
+		if (!Pilot.load_savefile(Cur_pilot->current_campaign)) {
+			// set single player squad image to multi if campaign can't be loaded
+			strcpy_s(Cur_pilot->s_squad_filename, Cur_pilot->m_squad_filename);
+		}
 	}
 
 	// init stuff to reflect new pilot
 	int i;
 	barracks_init_stats(&Cur_pilot->stats);
+	strcpy_s(stripped, Cur_pilot->image_filename);
+	barracks_strip_pcx(stripped);
 	for (i=0; i<Num_pilot_images; i++) {
-		strcpy_s(stripped, Cur_pilot->image_filename);
-		barracks_strip_pcx(stripped);
 		if (!stricmp(stripped, Pilot_image_names[i])) {
 			break;
 		}
 	}
 	Pic_number = i;
+
+	if (Game_mode & GM_MULTIPLAYER) {
+		strcpy_s(stripped, Cur_pilot->m_squad_filename);
+	} else {
+		strcpy_s(stripped, Cur_pilot->s_squad_filename);
+	}
+	barracks_strip_pcx(stripped);
 	for ( i=0; i<Num_pilot_squad_images; i++) {
-		strcpy_s(stripped, Cur_pilot->squad_filename);
-		barracks_strip_pcx(stripped);
 		if (!stricmp(stripped, Pilot_squad_image_names[i])) {
 			break;
 		}
@@ -621,13 +629,14 @@
 		return -1;
 	}
 
-	// set his image 
-	player_set_squad_bitmap(Cur_pilot, Cur_pilot->squad_filename);
+	// set pilot image
+	if (Game_mode & GM_MULTIPLAYER) {
+		player_set_squad_bitmap(Cur_pilot, Cur_pilot->m_squad_filename, true);
+	} else {
+		player_set_squad_bitmap(Cur_pilot, Cur_pilot->s_squad_filename, false);
+	}
 
-//	Skill_level = get_default_skill_level();
-
 	// MWA -- I think that we should be writing Cur_pilot here.
-	//write_pilot_file(!is_pilot_multi(Cur_pilot));
 	Pilot.save_player(Cur_pilot);
 
 	os_config_write_string(NULL, "LastPlayer", Cur_pilot->callsign);
@@ -756,7 +765,11 @@
 
 	// copy squad pic filename into pilot struct
 	if ((Pic_squad_number >= 0) && (Pic_squad_number < Num_pilot_squad_images)) {
-		strcpy_s(Cur_pilot->squad_filename, Pilot_squad_image_names[Pic_squad_number]);
+		if (Game_mode & GM_MULTIPLAYER) {
+			strcpy_s(Cur_pilot->m_squad_filename, Pilot_squad_image_names[Pic_squad_number]);
+		} else {
+			strcpy_s(Cur_pilot->s_squad_filename, Pilot_squad_image_names[Pic_squad_number]);
+		}
 	}
 
 	// play scroll sound
@@ -780,7 +793,11 @@
 
 	// copy squad pic filename into pilot struct
 	if ((Pic_squad_number >= 0) && (Pic_squad_number < Num_pilot_squad_images)){
-		strcpy_s(Cur_pilot->squad_filename, Pilot_squad_image_names[Pic_squad_number]);
+		if (Game_mode & GM_MULTIPLAYER) {
+			strcpy_s(Cur_pilot->m_squad_filename, Pilot_squad_image_names[Pic_squad_number]);
+		} else {
+			strcpy_s(Cur_pilot->s_squad_filename, Pilot_squad_image_names[Pic_squad_number]);
+		}
 	}
 
 	// play scroll sound
Index: code/playerman/player.h
===================================================================
--- code/playerman/player.h	(revision 9621)
+++ code/playerman/player.h	(working copy)
@@ -88,8 +88,10 @@
 	char				short_callsign[CALLSIGN_LEN + 1];	// callsign truncated to SHORT_CALLSIGN_PIXEL_W pixels
 	int				short_callsign_width;					// useful for mutliplayer chat boxes.
 	char				image_filename[MAX_FILENAME_LEN];	// filename of the image for this pilot
-	char				squad_filename[MAX_FILENAME_LEN];	// filename of the squad image for this pilot
-	char				squad_name[NAME_LENGTH + 1];			// pilot's squadron name
+	char				s_squad_filename[MAX_FILENAME_LEN];	// filename of the squad image for this pilot
+	char				s_squad_name[NAME_LENGTH + 1];			// pilot's squadron name
+	char				m_squad_filename[MAX_FILENAME_LEN];	// filename of the squad image for this pilot (multiplayer)
+	char				m_squad_name[NAME_LENGTH + 1];			// pilot's squadron name (multiplayer)
 	char				current_campaign[MAX_FILENAME_LEN]; // Name of the currently active campaign, or zero-length string if none
 	int				readyroom_listing_mode;
 
@@ -240,7 +242,7 @@
 void player_maybe_start_cargo_scan_sound();
 
 // will attempt to load an insignia bitmap and set it as active for the player
-void player_set_squad_bitmap(player *p, char *fname);
+void player_set_squad_bitmap(player *p, char *fnamem, bool ismulti);
 
 // set squadron
 void player_set_squad(player *p, char *squad_name);
Index: code/playerman/managepilot.cpp
===================================================================
--- code/playerman/managepilot.cpp	(revision 9621)
+++ code/playerman/managepilot.cpp	(working copy)
@@ -103,8 +103,10 @@
 	}
 
 	// unassigned squadron
-	strcpy_s(p->squad_name, XSTR("Unassigned", 1255));
-	strcpy_s(p->squad_filename, "");
+	strcpy_s(p->s_squad_name, XSTR("Unassigned", 1255));
+	strcpy_s(p->s_squad_filename, "");
+	strcpy_s(p->m_squad_name, XSTR("Unassigned", 1255));
+	strcpy_s(p->m_squad_filename, "");
 
 	// set him to be a single player pilot by default (the actual creation routines will change this if necessary)
 	p->flags &= ~PLAYER_FLAGS_IS_MULTI;
@@ -263,19 +265,24 @@
 	}	
 }
 
-// pick a random image for the passed player
+/*
+ * pick a random squad image for the passed player
+ * sets single & multi squad pic to the same image
+ *
+ * @param p	pointer to player
+ */
 void pilot_set_random_squad_pic(player *p)
 {	
 	// if there are no available pilot pics, set the image filename to null
 	if (Num_pilot_squad_images <= 0) {
-		player_set_squad_bitmap(p, "");
-		// strcpy_s(p->squad_filename, "");		
+		player_set_squad_bitmap(p, "", true);
+		player_set_squad_bitmap(p, "", false);
 	} else {
 		// pick a random name from the list
 		int random_index = rand() % Num_pilot_squad_images;		
 		Assert((random_index >= 0) && (random_index < Num_pilot_squad_images));
-		player_set_squad_bitmap(p, Pilot_squad_images_arr[random_index]); 
-		// strcpy_s(p->squad_filename, Pilot_squad_images_arr[random_index]);
+		player_set_squad_bitmap(p, Pilot_squad_images_arr[random_index], true);
+		player_set_squad_bitmap(p, Pilot_squad_images_arr[random_index], false);
 	}	
 }
 
@@ -330,13 +337,20 @@
 }
 
 // will attempt to load an insignia bitmap and set it as active for the player
-void player_set_squad_bitmap(player *p, char *fname)
+void player_set_squad_bitmap(player *p, char *fname, bool ismulti)
 {
 	// sanity check
 	if(p == NULL){
 		return;
 	}
 
+	char *squad_pic_p;
+	if (ismulti) {
+		squad_pic_p = p->m_squad_filename;
+	} else {
+		squad_pic_p = p->s_squad_filename;
+	}
+
 	// if he has another bitmap already - unload it
 	if (p->insignia_texture > 0) {
 		bm_release(p->insignia_texture);
@@ -345,30 +359,19 @@
 	p->insignia_texture = -1;
 
 	// try and set the new one
-	if (fname != p->squad_filename) {
-		strncpy(p->squad_filename, fname, MAX_FILENAME_LEN);
+	if (fname != squad_pic_p) {
+		strncpy(squad_pic_p, fname, MAX_FILENAME_LEN);
 	}
 
-	if (p->squad_filename[0] != '\0') {
+	if (squad_pic_p[0] != '\0') {
 		p->insignia_texture = bm_load_duplicate(fname);
-		
+
 		// lock is as a transparent texture
 		if (p->insignia_texture != -1) {
 			bm_lock(p->insignia_texture, 16, BMP_TEX_XPARENT);
 			bm_unlock(p->insignia_texture);
 		}
 	}
-
-	/*
-	flen = strlen(filename);
-	elen = strlen(ext);
-	Assert(flen < MAX_PATH_LEN);
-	strcpy_s(path, filename);
-	if ((flen < 4) || stricmp(path + flen - elen, ext)) {
-		Assert(flen + elen < MAX_PATH_LEN);
-		strcat_s(path, ext);
-	}
-	*/
 }
 
 // set squadron
@@ -379,7 +382,11 @@
 		return;
 	}
 
-	strncpy(p->squad_name, squad_name, NAME_LENGTH+1);
+	if (Game_mode & GM_MULTIPLAYER) {
+		strncpy(p->m_squad_name, squad_name, NAME_LENGTH+1);
+	} else {
+		strncpy(p->s_squad_name, squad_name, NAME_LENGTH+1);
+	}
 }
 
 void player::reset()
@@ -390,8 +397,10 @@
 	short_callsign_width = 0;
 
 	memset(image_filename, 0, sizeof(image_filename));
-	memset(squad_filename, 0, sizeof(squad_filename));
-	memset(squad_name, 0, sizeof(squad_name));
+	memset(s_squad_filename, 0, sizeof(s_squad_filename));
+	memset(s_squad_name, 0, sizeof(s_squad_name));
+	memset(m_squad_filename, 0, sizeof(m_squad_filename));
+	memset(m_squad_name, 0, sizeof(m_squad_name));
 
 	memset(current_campaign, 0, sizeof(current_campaign));
 
Index: code/parse/lua.cpp
===================================================================
--- code/parse/lua.cpp	(revision 9621)
+++ code/parse/lua.cpp	(working copy)
@@ -9713,9 +9713,21 @@
 	if(idx < 0 || idx >= Player_num)
 		return ade_set_error(L, "s", "");
 
-	return ade_set_args(L, "s", Players[idx].squad_name);
+	return ade_set_args(L, "s", Players[idx].s_squad_name);
 }
 
+ADE_FUNC(getMultiSquadronName, l_Player, NULL, "Gets current player multi squad name", "string", "Squadron name, or empty string if handle is invalid")
+{
+	int idx;
+	if(!ade_get_args(L, "o", l_Player.Get(&idx)))
+		return ade_set_error(L, "s", "");
+
+	if(idx < 0 || idx >= Player_num)
+		return ade_set_error(L, "s", "");
+
+	return ade_set_args(L, "s", Players[idx].m_squad_name);
+}
+
 //WMC - This isn't working
 /*
 ADE_FUNC(getSquadronImage, l_Player, NULL, "Squad image (string)", "Gets current player squad image")
Index: code/mission/missionparse.cpp
===================================================================
--- code/mission/missionparse.cpp	(revision 9621)
+++ code/mission/missionparse.cpp	(working copy)
@@ -655,7 +655,7 @@
 		if(!Fred_running && (Player != NULL) && (pm->squad_name[0] != '\0') && (Game_mode & GM_CAMPAIGN_MODE)){
 			mprintf(("Reassigning player to squadron %s\n", pm->squad_name));
 			player_set_squad(Player, pm->squad_name);
-			player_set_squad_bitmap(Player, pm->squad_filename);
+			player_set_squad_bitmap(Player, pm->squad_filename, false);
 		}
 	}
 
mantis2815-svn.patch (20,908 bytes)   

FUBAR-BDHR

2013-04-06 02:28

developer   ~0014902

Looks like it works. Tested everything except for the no .fc2 file scenario and I don't have anything set up to easily test that one.

niffiwan

2013-04-06 03:21

developer   ~0014905

OK. I've tested the no fc2 situation with TBP, renaming the EMW and RW VPs to something else to disable them. New pilots created at the initial screen and in the barracks get single player squad logos assigned. No logo on the Badger, but I don't know if TBP ships support squad logos on them or not, and I believe if the logo appears in the barracks it'll appear on the ship.

So, I'll be committing this patch shortly. If any other problems with the no fc2 scenario pop up in future, we can submit a new bug.

niffiwan

2013-04-06 03:23

developer   ~0014906

Fix committed to trunk@9622.

Related Changesets

fs2open: trunk r9622

2013-04-06 00:11

niffiwan


Ported: N/A

Details Diff
Fix mantis 2815: store single/multi squad names and images separately (in csg/plr respectively) Affected Issues
0002815
mod - /trunk/fs2_open/code/menuui/barracks.cpp Diff File
mod - /trunk/fs2_open/code/mission/missionparse.cpp Diff File
mod - /trunk/fs2_open/code/network/multi_data.cpp Diff File
mod - /trunk/fs2_open/code/network/multi_pinfo.cpp Diff File
mod - /trunk/fs2_open/code/network/multimsgs.cpp Diff File
mod - /trunk/fs2_open/code/network/multiui.cpp Diff File
mod - /trunk/fs2_open/code/network/multiutil.cpp Diff File
mod - /trunk/fs2_open/code/parse/lua.cpp Diff File
mod - /trunk/fs2_open/code/pilotfile/csg.cpp Diff File
mod - /trunk/fs2_open/code/pilotfile/csg_convert.cpp Diff File
mod - /trunk/fs2_open/code/pilotfile/pilotfile.h Diff File
mod - /trunk/fs2_open/code/pilotfile/plr.cpp Diff File
mod - /trunk/fs2_open/code/playerman/managepilot.cpp Diff File
mod - /trunk/fs2_open/code/playerman/player.h Diff File

Issue History

Date Modified Username Field Change
2013-03-20 07:07 FUBAR-BDHR New Issue
2013-04-01 07:40 niffiwan Assigned To => niffiwan
2013-04-01 07:40 niffiwan Status new => assigned
2013-04-01 07:41 niffiwan Note Added: 0014866
2013-04-04 09:41 niffiwan File Added: mantis2815-svn.patch
2013-04-04 09:45 niffiwan Note Added: 0014886
2013-04-04 09:45 niffiwan Status assigned => feedback
2013-04-04 20:18 FUBAR-BDHR Note Added: 0014889
2013-04-04 20:18 FUBAR-BDHR Status feedback => assigned
2013-04-04 22:49 MjnMixael Note Added: 0014890
2013-04-04 22:50 MjnMixael Note Edited: 0014890
2013-04-04 23:10 MjnMixael Note Edited: 0014890
2013-04-04 23:11 niffiwan Note Added: 0014891
2013-04-05 02:33 FUBAR-BDHR Note Added: 0014893
2013-04-05 02:49 FUBAR-BDHR Note Added: 0014894
2013-04-05 02:56 FUBAR-BDHR Note Edited: 0014894
2013-04-05 03:38 FUBAR-BDHR Relationship added related to 0002838
2013-04-05 04:02 niffiwan Note Added: 0014895
2013-04-05 05:32 niffiwan Note Added: 0014897
2013-04-05 09:46 niffiwan File Deleted: mantis2815-svn.patch
2013-04-05 09:46 niffiwan File Added: mantis2815-svn.patch
2013-04-05 09:47 niffiwan Note Added: 0014898
2013-04-05 09:47 niffiwan Status assigned => feedback
2013-04-05 09:48 niffiwan Relationship added related to 0002832
2013-04-05 09:49 niffiwan Note Edited: 0014898
2013-04-05 09:49 niffiwan Note Edited: 0014898
2013-04-06 00:20 niffiwan File Deleted: mantis2815-svn.patch
2013-04-06 01:42 niffiwan File Added: mantis2815-svn.patch
2013-04-06 01:43 niffiwan Note Edited: 0014898
2013-04-06 02:28 FUBAR-BDHR Note Added: 0014902
2013-04-06 02:28 FUBAR-BDHR Status feedback => assigned
2013-04-06 03:21 niffiwan Note Added: 0014905
2013-04-06 03:23 niffiwan Changeset attached => fs2open trunk r9622
2013-04-06 03:23 niffiwan Note Added: 0014906
2013-04-06 03:23 niffiwan Status assigned => resolved
2013-04-06 03:23 niffiwan Resolution open => fixed