/**********************************************************************
This file is part of Crack dot Com's free source code release of Golgotha.
for information about compiling & licensing issues visit this URL
 If that doesn't help, contact Jonathan Clark at 
  golgotha_source@usa.net (Subject should have "GOLG" in it) 
***********************************************************************/

#include "critical_graph.hh"
#include "path_api.hh"
#include "map.hh"
#include "map_cell.hh"
#include "map_man.hh"
#include 


g1_critical_graph_class::~g1_critical_graph_class()
//{{{
{
  if (pool)
    i4_free(pool);
  pool=0;
}
//}}}

void g1_critical_graph_class::clear_critical_graph()
//{{{
{
  if (pool)
    i4_free(pool);
  pool=0;

  pool_connections = 0;

  w32 size = sizeof(connection_class)*MAX_CRITICALS*MAX_CONNECTIONS;
  pool = (connection_class*)i4_malloc(size, "critical_connections");
  memset(pool,0,size);

  connection_class *current = pool;

  for (w32 j=1; jwrite_16(sw16(critical[j].x));
    f->write_16(sw16(critical[j].y));
  }
}
//}}}


void g1_critical_graph_class::save_graph(g1_saver_class *f)
//{{{
{
  w32 count=0, i,j;
  for (j=1; jref << conn->dist;
      for (int g=0; gsize[g];
    }
  }
}
//}}}


void g1_critical_graph_class::load_points(g1_loader_class *f)
//{{{
{
  *f >> criticals;

  for (w32 j=1; jread_16()) + 0.5;
    critical[j].y = i4_float(f->read_16()) + 0.5;
    critical[j].connection=0;
    critical[j].connections=0;
    critical[j].selected=0;
  }

  if (pool)
    i4_free(pool);
  pool = 0;
  pool_connections=0;
}
//}}}


void g1_critical_graph_class::load_graph(g1_loader_class *f)
//{{{
{
  if (pool)
    i4_free(pool);

  pool = 0;

  *f >> pool_connections;

  w32 size = sizeof(connection_class)*pool_connections;

  if (size)
    pool = (connection_class*)i4_malloc(size, "critical_connections");
  else pool=0;

  connection_class *conn = pool;

  for (w32 j=1; j> critical[j].connections;
    for (w32 i=0; i> conn->ref >> conn->dist;
      for (int g=0; g> conn->size[g];
    }
  }
}
//}}}


//{{{ Emacs Locals
// Local Variables:
// folded-file: t
// End:
//}}}