widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #06985
[Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
TiborB has proposed merging lp:~widelands-dev/widelands/ship_overlap into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/ship_overlap/+merge/290363
Attempt to fix an issue when two or more ships are sailing 'one above another', the ship now counts ships on its position and if more then 1, sleeps for 5 seconds. Test is done with probability of 10%, otwerwise we could end up with ships standing forever on the same spot.
It works, but still consider if the place for this test is right
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/ship_overlap into lp:widelands.
=== modified file 'src/logic/map_objects/bob.cc'
--- src/logic/map_objects/bob.cc 2016-02-09 16:29:48 +0000
+++ src/logic/map_objects/bob.cc 2016-03-29 20:01:14 +0000
@@ -694,6 +694,19 @@
// that contains a zero-length path.
return pop_task(game);
+ // Slowing down a ship if two or more on same spot
+ // Using probability of 10% and pausing it for 5 seconds
+ if (rand() % 10 == 0 && is_a(Ship, this)) {
+ Map& map = game.map();
+ const uint32_t ships_count
+ = map.find_bobs(Widelands::Area<Widelands::FCoords>(get_position(), 0), nullptr, FindBobShip());
+ assert (ships_count > 0);
+ if (ships_count > 1) {
+ molog ("Pausing the ship because %d ships on the same spot\n", ships_count);
+ return start_task_idle(game, descr().main_animation(), 5000);
+ }
+ }
+
if
(static_cast<Path::StepVector::size_type>(state.ivar1)
>=
Follow ups
-
[Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: noreply, 2016-03-31
-
Re: [Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: TiborB, 2016-03-31
-
[Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: GunChleoc, 2016-03-31
-
Re: [Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: TiborB, 2016-03-30
-
[Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: bunnybot, 2016-03-30
-
Re: [Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: GunChleoc, 2016-03-30
-
Re: [Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: GunChleoc, 2016-03-30
-
[Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: bunnybot, 2016-03-30
-
Re: [Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: TiborB, 2016-03-30
-
Re: [Merge] lp:~widelands-dev/widelands/ship_overlap into lp:widelands
From: GunChleoc, 2016-03-30