All Projects

IDProjectTask TypeCategorySeveritySummaryOpened
12727RockboxBugsGamesLowcalc_strength is Buggy in Plugin Superdom2012-08-125 Task Description

If you add a tank or a plane on a field the strenght does not increase at any time ( as expected ). E.g. place a tank on a field with a farm.

The Bug is located in superdom.c in lines 438 - 457

static int calc_strength(int colour, int x, int y) {

  int a, b, score=0;
  for (a = -1; a < 2; a++) {
      for (b = -1; b < 2; b++) {
          if ((b == 0 || a == 0) &&
              (board[x + a][y + b].colour == colour)) {
              score += 10;
              if(board[x + a][y + b].tank || board[x + a][y + b].farm) // <-- this is the BUG
                  score += 30;
              if(board[x + a][y + b].plane || board[x + a][y + b].ind) // <-- this is the BUG
                  score += 40;
              if(board[x + a][y + b].nuke)
                  score += 20;
              if(board[x + a][y + b].men)
                  score += (board[x + a][y + b].men*133/1000);
          }
      }
  }
  return score;

}

The Bug should be fixed by using this lines instead :

static int calc_strength(int colour, int x, int y) {

  int a, b, score=0;
  for (a = -1; a < 2; a++) {
      for (b = -1; b < 2; b++) {
          if ((b == 0 || a == 0) &&
              (board[x + a][y + b].colour == colour)) {
              score += 10;
              if(board[x + a][y + b].tank)
                  score += 30;
              if(board[x + a][y + b].farm)
                  score += 30;
              if(board[x + a][y + b].plane)
                  score += 40;
              if(board[x + a][y + b].ind)
                  score += 40;
              if(board[x + a][y + b].nuke)
                  score += 20;
              if(board[x + a][y + b].men)
                  score += (board[x + a][y + b].men*133/1000);
          }
      }
  }
  return score;

}

Showing tasks 1 - 1 of 1 Page 1 of 1

Available keyboard shortcuts

Tasklist

Task Details

Task Editing