[Widelands-dev] [Merge] lp:~widelands-dev/widelands/choose-attack-soldiers into lp:widelands

2019-05-07 Thread Benedikt Straub
Benedikt Straub has proposed merging 
lp:~widelands-dev/widelands/choose-attack-soldiers into lp:widelands.

Commit message:
Allow the player to choose the soldiers to send in the attack box

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #585981 in widelands: "Soldier choice in the attack box"
  https://bugs.launchpad.net/widelands/+bug/585981

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/choose-attack-soldiers/+merge/367041

The attack box contains two lists of soldiers: One for the attacking soldiers 
and one for the rest. Click on a soldier to move him to the other list. 
Ctrl-Click to move all soldiers.

If you just want to attack quickly and don“t care about soldier choice, you can 
still use the slider or the more/less buttons.

Note that one soldier will always remain in every militarysite. Currently the 
engine decides which soldier this is, and he will not be shown in the attack 
box. Ideally, all available soldiers should be shown, grouped by their 
building, and the player can then choose which soldier(s) remain(s) behind, but 
this would clutter up the interface too much in my opinion if there are many 
own militarysites, especially small ones, nearby.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/choose-attack-soldiers into lp:widelands.
=== modified file 'src/ai/defaultai_warfare.cc'
--- src/ai/defaultai_warfare.cc	2019-04-09 16:43:49 +
+++ src/ai/defaultai_warfare.cc	2019-05-07 12:22:42 +
@@ -481,7 +481,8 @@
 	}
 
 	// how many attack soldiers we can send?
-	int32_t attackers = player_->find_attack_soldiers(*flag);
+	std::vector soldiers;
+	int32_t attackers = player_->find_attack_soldiers(*flag, &soldiers);
 	assert(attackers < 500);
 
 	if (attackers > 5) {
@@ -499,7 +500,12 @@
 	player_number(), flag->get_position().x, flag->get_position().y, best_score, attackers,
 	enemy_sites[best_target].attack_counter + 1,
 	(gametime - enemy_sites[best_target].last_time_attacked) / 1000);
-	game().send_player_enemyflagaction(*flag, player_number(), static_cast(attackers));
+	std::vector attacking_soldiers;
+	for (int a = 0; a < attackers; ++a) {
+		// TODO(Nordfriese): We could now choose the soldiers we want to send
+		attacking_soldiers.push_back(soldiers[a]->serial());
+	}
+	game().send_player_enemyflagaction(*flag, player_number(), attacking_soldiers);
 	assert(1 <
 	   player_->vision(Map::get_index(flag->get_building()->get_position(), map.get_width(;
 	attackers_count_ += attackers;

=== modified file 'src/logic/game.cc'
--- src/logic/game.cc	2019-05-04 10:47:44 +
+++ src/logic/game.cc	2019-05-07 12:22:42 +
@@ -821,10 +821,11 @@
 
 void Game::send_player_enemyflagaction(const Flag& flag,
PlayerNumber const who_attacks,
-   uint32_t const num_soldiers) {
+   const std::vector& soldiers) {
 	if (1 < player(who_attacks)
-	   .vision(Map::get_index(flag.get_building()->get_position(), map().get_width(
-		send_player_command(*new CmdEnemyFlagAction(get_gametime(), who_attacks, flag, num_soldiers));
+	   .vision(Map::get_index(flag.get_building()->get_position(), map().get_width( {
+		send_player_command(*new CmdEnemyFlagAction(get_gametime(), who_attacks, flag, soldiers));
+	}
 }
 
 void Game::send_player_ship_scouting_direction(Ship& ship, WalkingDir direction) {

=== modified file 'src/logic/game.h'
--- src/logic/game.h	2019-03-01 16:24:48 +
+++ src/logic/game.h	2019-05-07 12:22:42 +
@@ -273,7 +273,7 @@
 	void send_player_change_training_options(TrainingSite&, TrainingAttribute, int32_t);
 	void send_player_drop_soldier(Building&, int32_t);
 	void send_player_change_soldier_capacity(Building&, int32_t);
-	void send_player_enemyflagaction(const Flag&, PlayerNumber, uint32_t count);
+	void send_player_enemyflagaction(const Flag&, PlayerNumber, const std::vector&);
 
 	void send_player_ship_scouting_direction(Ship&, WalkingDir);
 	void send_player_ship_construct_port(Ship&, Coords);

=== modified file 'src/logic/player.cc'
--- src/logic/player.cc	2019-05-04 10:47:44 +
+++ src/logic/player.cc	2019-05-07 12:22:42 +
@@ -950,20 +950,17 @@
 
 // TODO(unknown): Clean this mess up. The only action we really have right now is
 // to attack, so pretending we have more types is pointless.
-void Player::enemyflagaction(Flag& flag, PlayerNumber const attacker, uint32_t const count) {
-	if (attacker != player_number())
+void Player::enemyflagaction(Flag& flag, PlayerNumber const attacker,
+		const std::vector& soldiers) {
+	if (attacker != player_number()) {
 		log("Player (%d) is not the sender of an attack (%d)\n", attacker, player_number());
-	else if (count == 0)
-		log("enemyflagaction: count is 0\n");
-	else if (is_hostile(flag.owner())) {
+	} else if (soldiers.empty()) {
+		log("enemyflagaction: n

[Widelands-dev] [Merge] lp:~widelands-dev/widelands/choose-attack-soldiers into lp:widelands

2019-05-07 Thread bunnybot
Continuous integration builds have changed state:

Travis build 4908. State: failed. Details: 
https://travis-ci.org/widelands/widelands/builds/529279191.
Appveyor build 4689. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_choose_attack_soldiers-4689.
-- 
https://code.launchpad.net/~widelands-dev/widelands/choose-attack-soldiers/+merge/367041
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/choose-attack-soldiers into lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1825932-open-games into lp:widelands

2019-05-07 Thread bunnybot
Continuous integration builds have changed state:

Travis build 4909. State: failed. Details: 
https://travis-ci.org/widelands/widelands/builds/529451211.
Appveyor build 4690. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1825932_open_games-4690.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1825932-open-games/+merge/366860
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1825932-open-games into lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp