DELTA 28160 2964 832
SVN  ÛvÞtg®q ‘: €o H ® U”€‘2 FÇ@€… E°> O³=€K ]°w€x ƒ €q R»>€% I½=€„{ ]Ã'€ƒ( FÇ@€„: H ® „”€% yš	€‚	 ŽRÍ$struct tai_tile_state
{
  int uw_max;
  int worst_worked;
  int orig_worst_worked;
  int old_worst_worked;
};

***
  Select worker task suitable for the tilevoid tai_tile_worker_task_select(struct player *pplayer,
                                        struct city *pcity, struct tile *ptile,
                                        int cindex, struct unit_list *units,
                                        struct worker_task *worked,
                                        struct worker_task *unworked,
                                        struct tai_tile_state *state)
{
  int orig_value;
  bool potential_worst_worked = FALSE;

  if (!city_can_work_tile(pcity, ptile)) {
    return;
  }

  orig_value = city_tile_value(pcity, ptile, 0, 0);

  if (tile_worked(ptile) == pcity
      && orig_value < state->worst_worked) {
    state->worst_worked = orig_value;
    state->orig_worst_worked = orig_value;
    potential_worst_worked = TRUE;
  }

  as_transform_activity_iterate(act) {
    bool consider = TRUE;
    bool possible = FALSE;
    enum extra_cause cause;
    enum extra_rmcause rmcause;

    /* Do not request activities that already are under way. */
    unit_list_iterate(ptile->units, punit) {
      if (unit_owner(punit) == pplayer
          && unit_has_type_flag(punit, UTYF_SETTLERS)
          && punit->activity == act) {
        consider = FALSE;
        break;
      }
    } unit_list_iterate_end;

    if (!consider) {
      continue;
    }

    cause = activity_to_extra_cause(act);
    rmcause = activity_to_extra_rmcause(act);

    unit_list_iterate(units, punit) {
      struct extra_type *tgt = NULL;

      if (cause != EC_NONE) {
        tgt = next_extra_for_tile(ptile, cause, pplayer, punit);
      } else if (rmcause != ERM_NONE) {
        tgt = prev_extra_in_tile(ptile, rmcause, pplayer, punit);
      }

      if (can_unit_do_activity_targeted_at(punit, act, tgt, ptile)) {
        possible = TRUE;
        break;
      }
    } unit_list_iterate_end;

    if (possible) {
      int value = adv_city_worker_act_get(pcity, cindex, act);

      if (tile_worked(ptile) == pcity) {
        if ((value - orig_value) * TWMP > worked->want) {
          worked->want  = TWMP * (value - orig_value);
          worked->ptile = ptile;
          worked->act   = act;
          worked->tgt   = NULL;
        }
        if (value > state->old_worst_worked) {
potential_worst_worked = FALSE;
        } else {
          state->worst_worked = value;
        }
      } else {
        if (value > orig_value && value > state->uw_max) {
          state->uw_max = value;
          unworked->want  = TWMP * (value - orig_value);
          unworked->ptile = ptile;
          unworked->act   = act;
          unworked->tgt   = NULL;
        }
      }
    }
  } as_transform_activity_iterate_end;

  extra_type_iterate(tgt) {
    enum unit_activity act = ACTIVITY_LAST;
    bool removing = tile_has_extra(ptile, tgt);

    unit_list_iterate(units, punit) {
      if (removing) {
        as_rmextra_activity_iterate(try_act) {
act = try_act;
            break;
          }
        } as_rmextra_activity_iterate_end;
      } else {
        as_extra_activity_iterate(try_act) {
          if (is_extra_caused_by_action(tgt, try_act)
act = try_act;
            break;
          }
        } as_extra_activity_iterate_end;
      }
    } unit_list_iterate_end;

    if (act != ACTIVITY_LAST) {
      int value;
      int extra;
      bool consider = TRUE;
      struct road_type *proadproad = extra_road_get(tgt);

      value = adv_city_worker_extra_get(pcity, cindex, tgt);

      if (proad != NULL && road_provides_move_bonus(proad)) {
        int old_move_cost;
        int mc_multiplier = 1;
        int mc_divisor = 1;

* removal activity it's the value after the removal. */
        old_move_cost = tile_terrain(ptile)->movement_cost * SINGLE_MOVE;

        road_type_iterate(pold) {
if (road_provides_move_bonus(pold)
                && pold->move_cost < old_move_cost) {
              old_move_cost = pold->move_cost;
            }
          }
        } road_type_iterate_end;

        if (proad->move_cost < old_move_cost) {
          if (proad->move_cost >= terrain_control.move_fragments) {
            mc_divisor = proad->move_cost / terrain_control.move_fragments;
          } else {
            if (proad->move_cost == 0) {
              mc_multiplier = 2;
            } else {
              mc_multiplier = 1 - proad->move_cost;
            }
            mc_multiplier += old_move_cost;
          }
        }

if (removing) {
          extra = -extra;
        }
      } else {
        extra = 0;
      }

      value += extra;

      if (tile_worked(ptile) == pcity) {
        if ((value - orig_value) * TWMP > worked->want) {
          worked->want  = TWMP * (value - orig_value);
          worked->ptile = ptile;
          worked->act   = act;
          worked->tgt   = tgt;
        }
        if (value > state->old_worst_worked) {
potential_worst_worked = FALSE;
        } else {
          state->worst_worked = value;
        }
      } else {
        if (value > orig_value && value > state->uw_max) {
          state->uw_max = value;
          unworked->want  = TWMP * (value - orig_value);
          unworked->ptile = ptile;
          unworked->act   = act;
          unworked->tgt   = tgt;
        }
      }
    }
  } extra_type_iterate_end;

  if (potential_worst_worked) {
    /* Would still be worst worked even if we improved *it*. */
    state->old_worst_worked = state->worst_worked;
  }
}

***
  Select worker task suitable for the citystruct tai_tile_state state = { .uw_max = 0, .worst_worked = FC_INFINITY,
                                  .orig_worst_worked = 0, .old_worst_worked = FC_INFINITY }tai_tile_worker_task_select(pplayer, pcity, ptile, cindex, units, &worked, &unworked,
                                &state);
  } city_tile_iterate_end;

  if (worked.ptile == NULL
      || (state.old_worst_worked < state.uw_max
          && (state.uw_max - state.ENDREP
id: mdh.5qi.r28858/6144
type: file
pred: mdh.5qi.r28160/14817
count: 23
text: 28858 0 6116 12148 8be735bcfba361a29424cceb6bb553c1
props: 26905 227276 34 0 25e6c2f7558b7484000d4d090dea5b92
cpath: /branches/S2_6/ai/threaded/taicity.c
copyroot: 27474 /branches/S2_6

PLAIN
K 11
Makefile.am
V 25
file 6pj.5ck.r26863/23126
K 9
taicity.c
V 24
file mdh.5qi.r28858/6144
K 9
taicity.h
V 26
file mdj.5ck.r26905/228510
K 8
taimsg.c
V 23
file 7pd.5qi.r27562/776
K 8
taimsg.h
V 26
file 78q.5ck.r26905/227622
K 11
taiplayer.c
V 24
file 6pm.5qi.r27562/1036
K 11
taiplayer.h
V 23
file 6pn.5qi.r27562/512
K 12
threadedai.c
V 25
file 6pk.5ck.r27002/12389
END
ENDREP
id: 6pi.5qi.r28858/6792
type: dir
pred: 6pi.5qi.r28160/15466
count: 53
text: 28858 6408 371 371 d5f5ce7611b431ac6dcbf656108c89f2
props: 19316 2220 53 0 a527b216afb99426b763a1e313c531be
cpath: /branches/S2_6/ai/threaded
copyroot: 27474 /branches/S2_6

PLAIN
K 11
Makefile.am
V 24
file 5d.5ck.r26100/14492
K 10
aitraits.c
V 26
file 7k0.5ck.r26905/229736
K 10
aitraits.h
V 26
file 7k2.5ck.r26905/225228
K 7
classic
V 24
dir l53.5ck.r27002/13709
K 7
default
V 24
dir 6k3.5qi.r28854/27477
K 12
difficulty.c
V 25
file 1b4x.5ck.r27304/6957
K 12
difficulty.h
V 27
file 1b4z.5ck.r26905/225513
K 11
handicaps.c
V 26
file syo.5ck.r26905/225805
K 11
handicaps.h
V 26
file syq.5ck.r26905/226737
K 4
stub
V 25
dir 6k5.5ck.r26905/226459
K 8
threaded
V 23
dir 6pi.5qi.r28858/6792
END
ENDREP
id: 8.5qi.r28858/7567
type: dir
pred: 8.5qi.r28854/28257
count: 1801
text: 28858 7043 511 511 0ef1283420eb63aa20099d694f98dd79
props: 11108 11315 64 0 abac628483ea4fdfa3bea3a3a56e0532
cpath: /branches/S2_6/ai
copyroot: 27474 /branches/S2_6

PLAIN
K 9
ABOUT-NLS
V 24
file fu.5ck.r27270/69307
K 7
AUTHORS
V 24
file 5u.5ck.r22143/14016
K 7
COPYING
V 19
file 1h.0.r9643/400
K 9
ChangeLog
V 26
file 6l.5ck.r27473/7455495
K 7
INSTALL
V 21
file 6.5qi.r28849/211
K 11
Makefile.am
V 23
file 59.5qi.r28501/5905
K 4
NEWS
V 24
file 6m.5ck.r25634/30702
K 6
README
V 20
file 7.0.r4421/96382
K 2
ai
V 21
dir 8.5qi.r28858/7567
K 10
autogen.sh
V 24
file 12o.5ck.r25794/4003
K 9
bootstrap
V 23
dir 2p5.5qi.r28598/3780
K 6
client
V 21
dir d.5qi.r28856/9758
K 6
common
V 22
dir p.5qi.r28854/24886
K 12
configure.ac
V 23
file 149.5qi.r28839/661
K 4
data
V 21
dir w.5qi.r28827/3377
K 12
dependencies
V 23
dir 2yu.5qi.r28830/5992
K 3
doc
V 22
dir k7.5qi.r28823/2213
K 10
fc_version
V 24
file 2lo.5qj.r28788/7072
K 11
gen_headers
V 24
dir 1hsw.5qi.r28587/4510
K 2
m4
V 24
dir 12p.5qi.r28825/12206
K 7
scripts
V 23
dir 2yo.5qi.r28717/5437
K 6
server
V 22
dir z.5qi.r28854/14703
K 5
tests
V 22
dir 2g9.5ck.r27023/734
K 5
tools
V 24
dir 4pj.5qp.r28854/30923
K 12
translations
V 24
dir t0a.5qi.r28825/19801
K 7
utility
V 22
dir 1c.5qi.r28758/4379
K 3
vms
V 25
dir u9.5ck.r21528/1396085
K 5
win32
V 23
dir 2eu.5qi.r28346/1712
END
ENDREP
id: 3.5qi.r28858/8975
type: dir
pred: 3.5qi.r28856/11174
count: 19368
text: 28858 7808 1154 1154 956bb44d1439ab649bb08969dc12d26d
props: 28037 14463 292 0 9e1d5de0253c723466868990c52c129f
cpath: /branches/S2_6
copyroot: 27474 /branches/S2_6

PLAIN
K 5
S1_14
V 21
dir 3.21.r18109/18803
K 4
S2_0
V 21
dir 3.10x.r21862/4178
K 4
S2_1
V 22
dir 3.59e.r20026/11014
K 4
S2_2
V 21
dir 3.5cy.r21861/5036
K 4
S2_3
V 21
dir 3.5f2.r24391/5183
K 4
S2_4
V 21
dir 3.5ii.r28851/1812
K 4
S2_5
V 21
dir 3.5kv.r28850/1696
K 4
S2_6
V 21
dir 3.5qi.r28858/8975
K 11
freeciv-web
V 22
dir 3.5bl.r13594/14918
END
ENDREP
id: 1.0.r28858/9569
type: dir
pred: 1.0.r28856/11771
count: 9252
text: 28858 9217 339 339 e536f610eb84e3c5c7c98a19b163b8bb
cpath: /branches
copyroot: 0 /

PLAIN
K 8
branches
V 19
dir 1.0.r28858/9569
K 4
tags
V 19
dir 2.0.r28528/6475
K 5
trunk
V 21
dir 3.5ck.r28857/8889
K 7
website
V 21
dir 3ge.0.r22980/2263
END
ENDREP
id: 0.0.r28858/9889
type: dir
pred: 0.0.r28857/9281
count: 28858
text: 28858 9724 152 152 34e33b3947c5ed1cbe930aa64194ee66
cpath: /
copyroot: 0 /

mdh.5qi.t28857-1 modify true false /branches/S2_6/ai/threaded/taicity.c


9889 10036
