← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/ai_coverity into lp:widelands

 

TiborB has proposed merging lp:~widelands-dev/widelands/ai_coverity into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/ai_coverity/+merge/294132

Here I implemented few fixes to coverity findings from latest report. But look please at one question in the diff
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/ai_coverity into lp:widelands.
=== modified file 'src/ai/ai_help_structs.cc'
--- src/ai/ai_help_structs.cc	2016-04-11 06:45:29 +0000
+++ src/ai/ai_help_structs.cc	2016-05-09 14:23:07 +0000
@@ -199,6 +199,7 @@
 	  military_in_constr_nearby(0),
 	  area_military_presence(0),
 	  military_stationed(0),
+	  unconnected_nearby(false),
 	  military_unstationed(0),
 	  is_portspace(false),
 	  port_nearby(false),
@@ -464,7 +465,9 @@
 }
 
 // This is an struct that stores strength of players, info on teams and provides some outputs from these data
-PlayersStrengths::PlayerStat::PlayerStat() {}
+PlayersStrengths::PlayerStat::PlayerStat() :
+	team_number(0),
+	players_power(0) {}
 PlayersStrengths::PlayerStat::PlayerStat(Widelands::TeamNumber tc, uint32_t pp) :
 	team_number(tc), players_power(pp) {}
 

=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc	2016-04-24 07:35:20 +0000
+++ src/ai/defaultai.cc	2016-05-09 14:23:07 +0000
@@ -2984,6 +2984,7 @@
 			RoadCandidates.road_impossible(coords);
 			count += 1;
 		}
+		delete &path; // QUESTION- is this enough?
 	}
 
 	// Well and finally building the winning road

=== modified file 'src/logic/player.h'
--- src/logic/player.h	2016-03-10 15:00:32 +0000
+++ src/logic/player.h	2016-05-09 14:23:07 +0000
@@ -136,9 +136,24 @@
 	void set_see_all(bool const t) {see_all_ = t; view_changed_ = true;}
 	bool see_all() const {return see_all_;}
 
-	/// Data that are used and managed by AI. They are here to have it saved as a port of player's data
+	/// Data that are used and managed by AI. They are here to have it saved as a part of player's data
 	struct AiPersistentState {
-		AiPersistentState() : initialized(0) {}
+		AiPersistentState()
+		: initialized(0), // zero here is important, it means "~first time"
+		 colony_scan_area(0),
+		 trees_around_cutters(0),
+		 expedition_start_time(0),
+		 ships_utilization(0),
+		 no_more_expeditions(0),
+		 last_attacked_player(0),
+		 least_military_score(0),
+		 target_military_score(0),
+		 ai_personality_military_loneliness(0),
+		 ai_personality_attack_margin(0),
+		 ai_productionsites_ratio(0),
+		 ai_personality_wood_difference(0),
+		 ai_personality_early_militarysites(0),
+		 last_soldier_trained(0) {}
 
 		// Was initialized
 		uint8_t initialized;


Follow ups