<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39602 >
New patch: It selects new units on the tiles of the current units in
focus. It selects only 1 unit by tile, to avoid unit selection duplication .
Index: client/control.c
===================================================================
--- client/control.c (révision 13752)
+++ client/control.c (copie de travail)
@@ -2726,13 +2726,41 @@
}
/**************************************************************************
-...
+ Selects new units on the same tiles than the previous selected ones.
+ Allows only one unit by tile.
**************************************************************************/
void key_quickselect(enum quickselect_type qtype)
{
+ struct unit_list *punits = unit_list_new();
+ struct unit *punit2;
+ bool tiles[MAP_INDEX_SIZE], first;
+
+ memset(tiles, 0, sizeof(tiles));
+ /* Collect the units */
unit_list_iterate(get_units_in_focus(), punit) {
- struct unit *punit2 = quickselect(punit->tile, qtype);
+ if (tiles[punit->tile->index]) {
+ /* One unit by tile only */
+ continue;
+ }
- set_unit_focus_and_select(punit2);
+ punit2 = quickselect(punit->tile, qtype);
+ if (punit2) {
+ unit_list_append(punits, punit2);
+ }
+ tiles[punit->tile->index] = TRUE;
} unit_list_iterate_end;
+
+ /* Set them in the focus */
+ first = TRUE;
+ unit_list_iterate(punits, punit) {
+ if (first) {
+ set_unit_focus_and_select(punit);
+ first = FALSE;
+ } else {
+ add_unit_focus(punit);
+ }
+ } unit_list_iterate_end;
+
+ unit_list_unlink_all(punits);
+ unit_list_free(punits);
}
Index: client/control.c
===================================================================
--- client/control.c (révision 13752)
+++ client/control.c (copie de travail)
@@ -2726,13 +2726,41 @@
}
/**************************************************************************
-...
+ Selects new units on the same tiles than the previous selected ones.
+ Allows only one unit by tile.
**************************************************************************/
void key_quickselect(enum quickselect_type qtype)
{
+ struct unit_list *punits = unit_list_new();
+ struct unit *punit2;
+ bool tiles[MAP_INDEX_SIZE], first;
+
+ memset(tiles, 0, sizeof(tiles));
+ /* Collect the units */
unit_list_iterate(get_units_in_focus(), punit) {
- struct unit *punit2 = quickselect(punit->tile, qtype);
+ if (tiles[punit->tile->index]) {
+ /* One unit by tile only */
+ continue;
+ }
- set_unit_focus_and_select(punit2);
+ punit2 = quickselect(punit->tile, qtype);
+ if (punit2) {
+ unit_list_append(punits, punit2);
+ }
+ tiles[punit->tile->index] = TRUE;
} unit_list_iterate_end;
+
+ /* Set them in the focus */
+ first = TRUE;
+ unit_list_iterate(punits, punit) {
+ if (first) {
+ set_unit_focus_and_select(punit);
+ first = FALSE;
+ } else {
+ add_unit_focus(punit);
+ }
+ } unit_list_iterate_end;
+
+ unit_list_unlink_all(punits);
+ unit_list_free(punits);
}
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev