Example #1
0
  //
  // Save
  //
  // Save system data
  //
  void Save(BlockFile &bFile)
  {
    // Size of required buffer
    U32 bufferSize = WorldCtrl::CellMapX() * WorldCtrl::CellMapZ();

    // Allocate a buffer
    Game::TeamBitfield *buffer = new Game::TeamBitfield[bufferSize];
    Game::TeamBitfield *ptr = buffer;

    // Iterate the seen map
    for (U32 i = 0; i < bufferSize; ++i)
    {
      // Clear the data for this cell
      *ptr = 0;

      // Now set a bit for each team that has seen this cell
      for (U32 team = 0; team < teamCount; team++)
      {
        if (seeMap[0][team][0][i] & SEENMASK)
        {
          Game::TeamSet(*ptr, team);
        }
      }

      // Move to next cell
      ++ptr;
    }

    // Save the buffer to the blockfile
    bFile.OpenBlock(SAVEBLOCK);
    bFile.WriteToBlock(buffer, bufferSize * sizeof(Game::TeamBitfield));
    bFile.CloseBlock();    

    // Free up the buffer
    delete [] buffer;
  }