Changeset 18 for trunk


Ignore:
Timestamp:
Dec 19, 2005, 6:38:46 AM (14 years ago)
Author:
jtv
Message:

Refactored patches-to-go counting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gamelogic.cxx

    r17 r18  
    217217  m_cols(_cols),
    218218  m_intelligence(1),
    219   m_patches_to_go(m_rows*m_cols-mines),
     219  m_patches_to_go(m_rows*m_cols),
    220220  m_moves(0)
    221221{
     
    283283      for (int i = 0; i < bitsperchar; ++i)
    284284      {
    285     if (x & 1) m_patches_to_go -= place_mine_at(r,c+i);
     285    if (x & 1) place_mine_at(r,c+i);
    286286    x >>= 1;
    287287      }
     
    298298      for (int i = 0; i < bitsperchar; ++i)
    299299      {
    300     if (x & 1)
    301     {
    302       reveal_patch(r, c+i);
    303       --m_patches_to_go;
    304     }
     300    if (x & 1) reveal_patch(r, c+i);
    305301    x >>= 1;
    306302      }
     
    386382
    387383  p.mine();
     384  --m_patches_to_go;
    388385  for_neighbours(row,col,set_nearby_mine());
    389386  return true;
     
    419416    {
    420417      reveal_patch(row,col);
    421       if (!p.mined()) --m_patches_to_go;
    422418      throw Boom(pos, m_moves, p.mined());
    423419    }
     
    442438    p.reveal();
    443439    for_neighbours(row,col,reveal_nearby(p.mined()));
     440    if (row >= 0 && row < m_rows && col >= 0 && col < m_cols && !p.mined())
     441      --m_patches_to_go;
    444442  }
    445443}
     
    474472          reveal_patch(row,col);
    475473      changes.insert(Coords(row,col));
    476           if (!p.mined()) --m_patches_to_go;
    477474          for_zone<2,true>(row,col,set_add<UnfinishedPatch>(area));
    478475        }
Note: See TracChangeset for help on using the changeset viewer.