Rockbox

  • Status Unconfirmed
  • Percent Complete
    0%
  • Task Type Bugs
  • Category Games
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version Release 3.11
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by corpsman - 2012-08-12

FS#12727 - calc_strength is Buggy in Plugin Superdom

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;

}

As appear you have found the fix, can you provide it in form of a patch?

Unfortunatunely i don't know that much about c-programming, or bugtracking /git / patch things… Beeing proud that i came that far to report the bug.

I browsed the code direkt on the git and surely will be unable to compile rockbox. Do you have a link for an howto create a patch ? Maybe i give it a try.

And yes i play superdom really often, otherwise i wouldn't give me that much work to find the code and try to understand whats going on *g*.

If you have a git checkout, after doing the change, you can create a patch using "git diff" (e.g. git diff > superdom.patch).

Well as i wrote i browsed the file in my browser using this URL :

http://git.rockbox.org/?p=rockbox.git;a=blob;f=apps/plugins/superdom.c;h=1ef99dee30efe1886288a9af4c35a32e4094d9f9;hb=HEAD

So i do not have a git checkout. I even do not have git :). I will try to find out how i can install git on my machine ( i am not using that f* Windows stuff ). But if i am honest i would prever that someone who knows what he's doing, will do the rest..

On linux installing git is as easy as typing "sudo apt-get install git" in a terminal, or though some software center (e.g. on Ubuntu).

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing