function LoadSpecialLocationsFromTemp()
{
   // it still has the old objects in it
   
   deleteVariables("$specialLocations");
   
  %file = "~/tempspeciallocations" @ $saveid @ ".sav";
  
  %fo = new fileobject();
   
  %fo.OpenForRead(%file);
   
  // read in all cleared tiles
  
   for(%line = %fo.ReadLine();%line !$= "";%line = %fo.ReadLine())
   {
      %type = getWord(%line, 0);
      %x = getWord(%line, 1);
      %y = getWord(%line, 2);

      %obj =    new t2dStaticSprite() {
                     canSaveDynamicFields = "1";
                     layer = 2;  
                     scenegraph = "sg";
                     size =  "8 8";
                  };
                  
      %obj.SetPosition(%x, %y);

      switch$ (%type)
      {
         case "learningcenter":
            %obj.specialplace = "Learning Center";
            %obj.Setimagemap("building5");
         case "militarybase":      
            %obj.specialplace = "Military Base";
            %obj.Setimagemap("building5");
            %obj.guns = getWord(%line, 3);
            %obj.ammo = getWord(%line, 4);
            %obj.soldiers = getWord(%line, 5);
         case "casino":
            %obj.specialplace = "Casino";
            %obj.Setimagemap("building1");
         case "airport":
            %obj.specialplace = "Airport";
            %obj.Setimagemap("building5");
            %obj.fuel = getWord(%line, 3);
            %obj.food = getWord(%line, 4);
            %obj.spareparts = getWord(%line, 5);
            %obj.tires = getWord(%line, 6);
         case "cache":
            %obj.specialplace = "Cache";  // 1 time find
            %obj.Setimagemap("crate");
            %obj.guns = getWord(%line, 3);
            %obj.ammo = getWord(%line, 4);
            %obj.fuel = getWord(%line, 5);
            %obj.food = getWord(%line, 6);
            %obj.medicine = getWord(%line, 7);
            %obj.spareparts = getWord(%line, 8);
            %obj.tires = getWord(%line, 9);
         case "hospital":
            %obj.specialplace = "Hospital";
            %obj.Setimagemap("building4");
            %obj.medicine = getWord(%line, 3);
         case "farm":
            %obj.specialplace = "Farm";
            %obj.Setimagemap("building5");
            %obj.food = getWord(%line, 3);
         case "gasstation":
            %obj.specialplace = "Gas Station";
            %obj.Setimagemap("building6");
            %obj.fuel = getWord(%line, 3);
            %obj.tires = getWord(%line, 4);
         case "autocenter":
            %obj.specialplace = "Auto Center";  // 1 time upgrade
            %obj.Setimagemap("building3");            
         case "TruckDepot":
            %obj.specialplace = "Truck Depot";
            %obj.Setimagemap("building2");
            %obj.fuel = getWord(%line, 3);
            %obj.tires = getWord(%line, 4);
      }
      
      if($specialLocations $= "")
         $specialLocations = %obj;
      else
         $specialLocations = $specialLocations SPC %obj;
   }      
   %fo.close();   
}

function SaveSpecialLocationsToTemp()
{
   %fo = new fileobject();
     
   %file = "~/tempspeciallocations" @ $saveid @ ".sav";
      
   %fo.OpenForWrite(%file);
   
   %count = getWordCount($specialLocations);
   
   for(%i=0;%i<%count;%i++)
   {
      %obj = getWord($specialLocations, %i);
      
      %line = "";
      
      switch$ (%obj.specialplace)
      {
         case "Military Base":
            %line = "militarybase" SPC %obj.GetPosition() SPC %obj.guns SPC %obj.ammo SPC %obj.soldiers;
         case "Airport":
            %line = "airport" SPC %obj.GetPosition() SPC %obj.fuel SPC %obj.food SPC %obj.spareparts SPC %obj.tires;
         case "Cache":
            %line = "cache" SPC %obj.GetPosition() SPC %obj.guns SPC %obj.ammo SPC %obj.fuel SPC %obj.food SPC %obj.medicine SPC %obj.spareparts SPC %obj.tires;
         case "Hospital":
            %line = "hospital" SPC %obj.GetPosition() SPC %obj.medicine;
         case "Farm":
            %line = "farm" SPC %obj.GetPosition() SPC %obj.food;
         case "Gas Station":
            %line = "gasstation" SPC %obj.GetPosition() SPC %obj.fuel SPC %obj.tires;
         case "Truck Depot":
            %line = "truckdepot" SPC %obj.GetPosition() SPC %obj.fuel SPC %obj.tires;
         case "Auto Center":
            %line = "autocenter" SPC %obj.GetPosition();
         case "Learning Center":
            %line = "learningcenter" SPC %obj.GetPosition();
         case "Casino":
            %line = "casino" SPC %obj.GetPosition();
      }

      %fo.WriteLine(%line);                        
   }
      
   %fo.close();
}

function LoadCitiesFromTemp()
{
   for(%i=1;%i<=100;%i++)
   {
      if($CapturedCities[%i] !$= "")
      {
         for(%j=1;%j<=8;%j++)
         {
            %sprite = $CapturedCities[%i] @ %j;
            %sprite.visible = false;
         }
      }
   }
}

function SaveNukesToTemp()
{
   %fo = new fileobject();
  
   %file = "~/tempnukes.sav";
 
   %fo.OpenForWrite(%file);   
   
   for(%i=1;%i<=30;%i++)
   {
      %captured = "";
      %silo = "silo" @ %i;
      
      if($silos[%silo] $= true)
      {
         if(%silo.captured $= true)
            %captured = "captured";
            
         %fo.WriteLine("silo" SPC %silo SPC %captured);
      }
   }   
   
   %fo.close();
}

function LoadNukesFromTemp()
{
   %fo = new fileobject();
  
   %file = "~/tempnukes.sav";

   %ret = %fo.OpenForRead(%file);
   
   for(%line = %fo.ReadLine();%line !$= "";%line = %fo.ReadLine())
   {
      %desc = getWord(%line, 0);
      
      $silos[getWord(%line, 1)] = true;
      
      if(getWord(%line, 2) $= "captured")
      {
         %silo = getWord(%line, 1);
         %silo.captured = true;
         %silo.SetBlendColor("0 202 41 255");
      }
   }
      
   %fo.close();
}