← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1750561 into lp:widelands

 

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

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1750561/+merge/338352

When looking for open sea, it just ignores first 4 fields in a direction. 
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1750561 into lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc	2018-02-20 11:57:18 +0000
+++ src/ai/defaultai.cc	2018-02-20 21:15:23 +0000
@@ -390,7 +390,7 @@
 		case SchedulerTaskId::KMarineDecisions:
 			// if function returns false, we can postpone for next call
 			{
-				const uint8_t wait_multiplier = (marine_main_decisions()) ? 1 : 5;
+				const uint8_t wait_multiplier = (marine_main_decisions(gametime)) ? 1 : 5;
 				set_taskpool_task_time(gametime + wait_multiplier * kMarineDecisionInterval,
 				                       SchedulerTaskId::KMarineDecisions);
 			}

=== modified file 'src/ai/defaultai.h'
--- src/ai/defaultai.h	2018-02-16 21:04:59 +0000
+++ src/ai/defaultai.h	2018-02-20 21:15:23 +0000
@@ -269,7 +269,7 @@
 	void expedition_management(Widelands::ShipObserver&);
 	// considering trees, rocks, mines, water, fish for candidate for colonization (new port)
 	uint8_t spot_scoring(Widelands::Coords candidate_spot);
-	bool marine_main_decisions();
+	bool marine_main_decisions(uint32_t);
 	bool check_ships(uint32_t);
 	bool attempt_escape(Widelands::ShipObserver& so);
 

=== modified file 'src/ai/defaultai_seafaring.cc'
--- src/ai/defaultai_seafaring.cc	2018-02-18 21:01:58 +0000
+++ src/ai/defaultai_seafaring.cc	2018-02-20 21:15:23 +0000
@@ -103,7 +103,12 @@
 // and makes two decisions:
 // - build a ship
 // - start preparation for expedition
-bool DefaultAI::marine_main_decisions() {
+bool DefaultAI::marine_main_decisions(const uint32_t gametime) {
+	if (gametime > last_seafaring_check_ + 20000U) {
+		const Map& map = game().map();
+		map_allows_seafaring_ = map.allows_seafaring();
+		last_seafaring_check_ = gametime;
+	}
 	if (!map_allows_seafaring_ &&
 	    count_buildings_with_attribute(BuildingAttribute::kShipyard) == 0 && allships.empty()) {
 		return false;
@@ -541,6 +546,9 @@
 			if (!(map.get_fcoords(tmp_coords).field->nodecaps() & MOVECAPS_SWIM)) {
 				break;
 			}
+			if (i <= 4) { // Four fields from the ship is too close for "open sea"
+				continue;
+			}
 			if (i == 5) {
 				// If open sea goes at least 5 fields from the ship this is considerd a
 				// candidate, but worse than directions in new_teritory_directions

=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc	2017-11-01 18:09:04 +0000
+++ src/logic/map_objects/tribes/ship.cc	2018-02-20 21:15:23 +0000
@@ -582,7 +582,7 @@
 						}
 				}
 				// if we are here, it seems something really strange happend.
-				log("WARNING: ship was not able to start exploration. Entering WAIT mode.");
+				log("WARNING: ship %s was not able to start exploration. Entering WAIT mode.\n", shipname_.c_str());
 				ship_state_ = ShipStates::kExpeditionWaiting;
 				return start_task_idle(game, descr().main_animation(), 1500);
 			}


Follow ups