示例#1
0
  //
  // Export
  //
  // Export this footprint to the given file name
  //
  Bool Type::Export(const char *fileName)
  {
    PTree tree;
    FScope *root, *cellInfo;
  
    // Add the top level scope
    root = tree.GetGlobalScope()->AddFunction("ConfigureFootPrint");

    // Get the layer used for zipping
    Layer &layer = GetLayer(LAYER_LOWER);

    // Save out the grid
    for (S32 z = 0; z <= size.z; z++)
    {
      for (S32 x = 0; x <= size.x; x++)
      {
        // Write out cell info
        cellInfo = root->AddFunction("SetupCell");
        cellInfo->AddArgInteger(x);
        cellInfo->AddArgInteger(z);

        // Is this cell on the footprint
        if (x < size.x && z < size.z)
        {
          Cell &cell = GetCell(x, z);
          StdSave::TypeU32(cellInfo, "Hide", cell.GetFlag(HIDE));
          StdSave::TypeU32(cellInfo, "SetBase", cell.GetFlag(SETBASE));
          StdSave::TypeU32(cellInfo, "Second", cell.GetFlag(SECOND));
          StdSave::TypeU32(cellInfo, "Dirs", cell.dirs);
          StdSave::TypeU32(cellInfo, "ClaimLo", cell.GetFlag(CLAIMLO));
          StdSave::TypeU32(cellInfo, "ClaimHi", cell.GetFlag(CLAIMHI));
          StdSave::TypeU32(cellInfo, "BlockLOS", cell.GetFlag(BLOCKLOS));

          if (cell.GetFlag(SURFACE))
          {
            MoveTable::KeyInfo *info = MoveTable::FindSurfaceInfo(cell.surface);

            if (info)
            {
              StdSave::TypeString(cellInfo, "Surface", info->ident.str);
            }
          }
        }

        Layer::Cell &cell = layer.GetCell(x, z);
        StdSave::TypeU32(cellInfo, "Zip", cell.GetFlag(Layer::ZIP));
      }
    }
  
    // Save out to disk
    return (tree.WriteTreeText(fileName));
  }