title: Map Saving
author: tiglari

Map saving is done by the calling TTMapBrush.SaveAsText
in QkMapObjects.  This is triggered in slightly different
ways by the regular build menu (qSaveFile), and the <act>File|SaveAs|*.map</act>
menu item/dialog (TQForm1.Save), both in QkMapObjects. there
is duplication of the code involved in reading the map
saving config options; the build menu code does it in
Python (quarkpy.mapquakemenu.writemapfile), the file-menu
code in delphi (QMap/QMapFile.SaveFile).



The relevant object hierarchy is:

<code>
TTreeMap
  TTreeMapSpec (can have writeable specifics)
     TTreeMapGroup (can have sub-polys/beziers)
        TTreeMapBrush (brush entity)
     TTreeMapEntity
        TDuplicator (hmm, also can have sub-stuff)
  TTexturedTreeMap
     TFace
     TBezier
</code>

TTreeMapBrush writes the worldspawn specifics, contained
polys, and beziers, and then, at the end, invokes
TTMapGroup.SaveAsText to write out the brush and point
entities in the map structure (outside of the scope of the
worldspawn entities).  To keep things confusing, several
of the routines pass a Flags parameter, co-named with one
of the fields of QObject, which keeps track of some
parameters controlling map-writing.  Groups are for example
perused for beziers to write only if soIgnoreToBuild is
set in Flags, and vfIgnoreToBuild is set in ViewFlags,
which is the TTreeMapGroup property encoding the view/build
flags in groups in the tree-structure.

Originally, the beziers were collected with ListeEntites
with the Cat set at [ecBezier], but this caused the
ignoretobuild flags to be ignored, so currently a special
ListeBeziers function is used.  Perhaps ListeEntites should
be reinstated with a Flags argument.

