View Issue Details

IDProjectCategoryView StatusLast Update
0003105FSSCPdesign flawpublic2014-09-13 03:17
ReporterMageKing17 Assigned ToMageKing17  
PrioritylowSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Target Version3.7.2 
Summary0003105: radarsetup.cpp radar_plot_object() creates a copy of a ship_info object instead of using a pointer to it
DescriptionFortunately, this is less of a problem than it could be due to the default assignment operator behavior being to use the assignment operator for every attribute of the class, and none of the problematic ones are referenced in this function. Still, it's an unnecessary copy operation, and should almost certainly be a pointer instead.

Patch attached.
Additional InformationAssigning to niffiwan per conversation on #scp, but if anybody else wants to review and commit it, feel free.
TagsNo tags attached.

Activities

MageKing17

2014-09-11 23:39

developer  

radarsetup.cpp.patch (1,169 bytes)   
Index: code/radar/radarsetup.cpp
===================================================================
--- code/radar/radarsetup.cpp	(revision 11071)
+++ code/radar/radarsetup.cpp	(working copy)
@@ -315,14 +315,14 @@
 		if (awacs_level < 1.0f)
 			b->flags |= BLIP_DRAW_DISTORTED;
 
-		ship_info Iff_ship_info = Ship_info[Ships[objp->instance].ship_info_index];
+		ship_info *Iff_ship_info = &Ship_info[Ships[objp->instance].ship_info_index];
 
-		if (Iff_ship_info.radar_image_2d_idx >= 0 || Iff_ship_info.radar_color_image_2d_idx >= 0)
+		if (Iff_ship_info->radar_image_2d_idx >= 0 || Iff_ship_info->radar_color_image_2d_idx >= 0)
 		{
-			b->radar_image_2d = Iff_ship_info.radar_image_2d_idx;
-			b->radar_color_image_2d = Iff_ship_info.radar_color_image_2d_idx;
-			b->radar_image_size = Iff_ship_info.radar_image_size;
-			b->radar_projection_size = Iff_ship_info.radar_projection_size_mult;
+			b->radar_image_2d = Iff_ship_info->radar_image_2d_idx;
+			b->radar_color_image_2d = Iff_ship_info->radar_color_image_2d_idx;
+			b->radar_image_size = Iff_ship_info->radar_image_size;
+			b->radar_projection_size = Iff_ship_info->radar_projection_size_mult;
 		}
 	}
 
radarsetup.cpp.patch (1,169 bytes)   

niffiwan

2014-09-13 03:16

developer   ~0016277

Last edited: 2014-09-13 03:17

looks good to me and tests OK.

niffiwan

2014-09-13 03:17

developer   ~0016278

Fix committed to trunk@11074.

Related Changesets

fs2open: trunk r11074

2014-09-12 23:51

niffiwan


Ported: N/A

Details Diff
Fix mantis 3105 (from MageKing17)

Use a pointer for reading radar IFF info, not an object copy
Affected Issues
0003105
mod - /trunk/fs2_open/code/radar/radarsetup.cpp Diff File

Issue History

Date Modified Username Field Change
2014-09-11 23:39 MageKing17 New Issue
2014-09-11 23:39 MageKing17 Status new => assigned
2014-09-11 23:39 MageKing17 Assigned To => niffiwan
2014-09-11 23:39 MageKing17 File Added: radarsetup.cpp.patch
2014-09-11 23:39 MageKing17 Status assigned => code review
2014-09-13 03:16 niffiwan Note Added: 0016277
2014-09-13 03:16 niffiwan Assigned To niffiwan => MageKing17
2014-09-13 03:16 niffiwan Status code review => assigned
2014-09-13 03:17 niffiwan Note Edited: 0016277
2014-09-13 03:17 niffiwan Changeset attached => fs2open trunk r11074
2014-09-13 03:17 niffiwan Note Added: 0016278
2014-09-13 03:17 niffiwan Status assigned => resolved
2014-09-13 03:17 niffiwan Resolution open => fixed