unit saving;

interface

uses vfm, variables, buildings, units, sysutils, global;

procedure SaveMap(file_name : string);

implementation

procedure SaveMap(file_name : string);
var
f : textfile;
i1, i2 : integer;
s : string;
begin
assignfile(f, file_name);
rewrite(f);

writeln(f, '**Developed by grouzd[E]v (Grouzdev Dmitry)');
writeln(f, '**Special for Delphi Game Development contest (http://code.rpro.ru, http://www.delphimaster.ru)');
writeln(f, '**URL: http://www.grouzdev.nm.ru');
writeln(f, '**E-mail: dmitry_grouzdev@mail.ru');
writeln(f, '**ICQ: 243059969');
writeln(f, '');
                             
with landscape do
  begin
    writeln(f, 'MAP_SCALE ', sx:8:4, ' ', sy:8:4, ' ', sz:8:4);
    {writeln(f, 'LANDSCAPE ', landscape_file_name, ' ', landscape_colors_name,
       ' ', landscape_texture_name);}
    writeln(f, 'FOG ', fog_destination_density:8:4, ' ', fog_height_density:8:4);
  end;

writeln(f, 'CREDITS 1000');

writeln(f, 'BASE ', gbase.base1.map_x, ' ', gbase.base1.map_y);
for i1 := 1 to total_turrels do
  writeln(f, 'TURREL ', gTurrels[i1].base.map_x, ' ', gTurrels[i1].base.map_y);
for i1 := 1 to total_trees do
  writeln(f, 'TREE ', gTrees[i1].stem.map_x, ' ', gTrees[i1].stem.map_y);

with pathmap do
  for i1 := 1 to width do
    for i2 := 1 to height do
      if map[i1, i2].build then
        writeln(f, 'BUILD ', i1, ' ', i2);

with pathmap do
  for i1 := 1 to width do
    for i2 := 1 to height do
      if map[i1, i2].walk then
        writeln(f, 'WALK ', i1, ' ', i2);

closefile(f);
end;

end.
