<URL: http://bugs.freeciv.org/Ticket/Display.html?id=34460 >
Minor optimization to ai_data_phase_init(). There is no point to
iterate through all unit classes to find transportable classes, if
unit has no transporter capacity at all. Also fixes a problem that
warships were considered to carry invasion forces.
- ML
diff -Nurd -X.diff_ignore freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c 2006-07-17 23:56:47.000000000 +0300
+++ freeciv/ai/aidata.c 2007-01-24 19:13:50.000000000 +0200
@@ -269,14 +269,16 @@
if (is_sailing_unit(punit)) {
/* If the enemy has not started sailing yet, or we have total
* control over the seas, don't worry, keep attacking. */
- unit_class_iterate(punitclass) {
- if (punitclass->move_type == LAND_MOVING
- && can_unit_type_transport(punit->type, punitclass)) {
- /* Enemy can transport some land units! */
- ai->threats.invasions = TRUE;
- break;
- }
- } unit_class_iterate_end;
+ if (get_transporter_capacity(punit) > 0) {
+ unit_class_iterate(punitclass) {
+ if (punitclass->move_type == LAND_MOVING
+ && can_unit_type_transport(punit->type, punitclass)) {
+ /* Enemy can transport some land units! */
+ ai->threats.invasions = TRUE;
+ break;
+ }
+ } unit_class_iterate_end;
+ }
/* The idea is that while our enemies don't have any offensive
* seaborne units, we don't have to worry. Go on the offensive! */
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev