~ubuntu-branches/ubuntu/maverick/lordsawar/maverick

« back to all changes in this revision

Viewing changes to src/path.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2010-04-10 09:29:33 UTC
  • mfrom: (1.1.9 upstream) (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100410092933-23uq4dxig30kmtcw
Tags: 0.1.8-1
* New upstream release.
* Add misc:Depends for -data package.
* Bump Standards Version to 3.8.4. (No changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
    return retval;
112
112
}
113
113
 
114
 
bool Path::checkPath(Stack* s)
 
114
bool Path::checkPath(Stack* s, int enemy_city_avoidance, int enemy_stack_avoidance)
115
115
{
116
116
    if (empty())
117
117
        return true;
122
122
        secondlast--;
123
123
        for (iterator it = begin(); it != secondlast; it++)
124
124
          {
125
 
            if (PathCalculator::isBlocked(s, *it) == false)
 
125
            if (PathCalculator::isBlocked(s, *it, enemy_city_avoidance, 
 
126
                                          enemy_stack_avoidance) == false)
126
127
              {
127
128
                valid = false;
128
129
                break;
176
177
        if (checkJoin == true)
177
178
          {
178
179
            Stack *other_stack = GameMap::getStack(c->getPos() + Vector<int>(i,j));
179
 
            if (other_stack && s->canJoin(other_stack) == false)
 
180
            if (other_stack && GameMap::canJoin(s,other_stack) == false)
180
181
              continue;
181
182
          }
182
183
        int distance = dist (s->getPos(), c->getPos() + Vector<int>(i, j));
200
201
            if (checkJoin == true)
201
202
              {
202
203
                Stack *other_stack = GameMap::getStack(c->getPos() + Vector<int>(i,j));
203
 
                if (other_stack && s->canJoin(other_stack) == false)
 
204
                if (other_stack && GameMap::canJoin(s,other_stack) == false)
204
205
                  continue;
205
206
              }
206
207
            int dist = calculate(s, c->getPos() + Vector<int>(i, j), zigzag);
245
246
  // Finally, all that is left is finding the minimum distance way from start
246
247
  // point to destination.
247
248
 
248
 
  PathCalculator pc = PathCalculator(s, zigzag);
 
249
    
 
250
  int enemy_city_avoidance = -1;
 
251
  int enemy_stack_avoidance = -1;
 
252
  if (s->getOwner() && s->getOwner()->isComputer())
 
253
    {
 
254
      //If we're a computer player we don't let enemy stacks and cities
 
255
      //prevent us from reaching our destination.  When we encounter them
 
256
      //we'll fight, but we try not to encounter them.
 
257
      enemy_city_avoidance = 10;
 
258
      enemy_stack_avoidance = 10;
 
259
    }
 
260
  PathCalculator pc = PathCalculator(s, zigzag, enemy_city_avoidance, 
 
261
                                     enemy_stack_avoidance);
249
262
 
250
263
  Path *calculated_path = pc.calculate(dest, moves, turns, zigzag);
251
264
  if (calculated_path->size())
256
269
 
257
270
  //calculate when the waypoints show no more movement possible
258
271
  guint32 pathcount = 0;
259
 
  guint32 moves_left = s->getGroupMoves();
 
272
  guint32 moves_left = s->getMoves();
260
273
  for (iterator it = begin(); it != end(); it++)
261
274
    {
262
275
      guint32 moves = s->calculateTileMovementCost(*it);