Example #1
0
void CAiMgrFile::write()
{
	// opening the file
	FILE *outf=fopen(_filename.c_str(),"wt");
	if (outf==0)
	{
		nlwarning("Failed to open file for writing: %s",_filename.c_str());
		return;
	}
	nlinfo("WRITING: %s",_filename.c_str());

	// writing the file header
	fprintf(outf,"<?xml version=\"1.0\"?>\n");
	fprintf(outf,"<FORM Version=\"0.1\" State=\"modified\">\n");
	writeOpenStruct(outf,1);

	// writing the static fields
	writeAtom(outf,2,"Name",_filename);
	writeAtom(outf,2,"Prim",_primFilename);

	// iterating through the managers to be written to the file
	uint i;
	writeOpenArray(outf,2,"Child");
	for (i=0;i<_children.size();i++)
		_children[i]->write(outf,3);
	writeCloseArray(outf,2);

	// writing the file footer
	writeCloseStruct(outf,1);
	fprintf(outf,"</FORM>\n");

	// closing the file
	fclose(outf);
}
Example #2
0
void CAiMgrLocation::write(FILE *outf,uint indent)
{
	writeOpenStruct(outf,indent,_name);

	// writing the static fields
	writeAtom(outf,indent+1,"Name",_name);
	writeAtom(outf,indent+1,"LocationType",_type);
	writeAtom(outf,indent+1,"Boundary",_boundary);

	writeCloseStruct(outf,indent);
}
Example #3
0
void CAiMgrInstance::write(FILE *outf,uint indent)
{
	uint i;

	writeOpenStruct(outf,indent,_name);

	// writing the static fields
	writeAtom(outf,indent+1,"Name",_name);
	writeAtom(outf,indent+1,"Boundary",_boundary);
	writeAtom(outf,indent+1,"CreatureLimit",_creatureLimit);

	// writing spawn points
	if (!_spawn.empty())
	{
		writeOpenArray(outf,indent+1,"Spawn");
		for (i=0;i<_spawn.size();i++)		_spawn[i]->write(outf,indent+2);
		writeCloseArray(outf,indent+1);
	}

	// writing populations
	if (!_population.empty())
	{
		writeOpenArray(outf,indent+1,"Population");
		for (i=0;i<_population.size();i++)	_population[i]->write(outf,indent+2);
		writeCloseArray(outf,indent+1);
	}

	// writing locations
	if (!_location.empty())
	{
		writeOpenArray(outf,indent+1,"Location");
		for (i=0;i<_location.size();i++)	_location[i]->write(outf,indent+2);
		writeCloseArray(outf,indent+1);
	}

	// writing children
	if (!_children.empty())
	{
		writeOpenArray(outf,indent+1,"Children");
		for (i=0;i<_children.size();i++)	_children[i]->write(outf,indent+2);
		writeCloseArray(outf,indent+1);
	}

	writeCloseStruct(outf,indent);
}
Example #4
0
void CAiMgrPopulation::write(FILE *outf,uint indent)
{
	writeOpenStruct(outf,indent,_name);

	// writing the static fields
	writeAtom(outf,indent+1,"Name",_name);
	writeAtom(outf,indent+1,"CreatureType",_creatureType.toString());
	writeAtom(outf,indent+1,"Population",_quantity);
	writeAtom(outf,indent+1,"MinSpawnTime",_minTime);
	writeAtom(outf,indent+1,"MaxSpawnTime",_maxTime);
	writeAtom(outf,indent+1,"Orientation",_orientation);

	writeCloseStruct(outf,indent);
}
Example #5
0
void CAiMgrSpawn::write(FILE *outf,uint indent)
{
	writeAtom(outf,indent,"",_place.c_str());
}
Example #6
0
int main(int argc, char *argv[])
{
  bool_t analyze_output, equilibria_only;
  int    niter, nact;

  Atom *atom;
  Molecule *molecule;

  /* --- Read input data and initialize --             -------------- */

  setOptions(argc, argv);
  getCPU(0, TIME_START, NULL);
  SetFPEtraps();

  readInput();
  spectrum.updateJ = TRUE;
 
  getCPU(1, TIME_START, NULL);
  readAtmos(&atmos, &geometry);
  if (atmos.Stokes) Bproject();
  fillMesh(&geometry);

  readAtomicModels();
  readMolecularModels();
  SortLambda();
  
  getBoundary(&atmos, &geometry);

  Background(analyze_output=TRUE, equilibria_only=FALSE);

  getProfiles();
  initSolution();
  initScatter();

  getCPU(1, TIME_POLL, "Total initialize");
 
  /* --- Solve radiative transfer for active ingredients -- --------- */

  Iterate(input.NmaxIter, input.iterLimit);

  adjustStokesMode(atom);
  niter = 0;
  while (niter < input.NmaxScatter) {  
    if (solveSpectrum(FALSE, FALSE) <= input.iterLimit) break;
    niter++;
  }
  /* --- Write output files --                     ------------------ */
 
  getCPU(1, TIME_START, NULL);

  writeInput();
  writeAtmos(&atmos);
  writeGeometry(&geometry);
  writeSpectrum(&spectrum);
  writeFlux(FLUX_DOT_OUT);

  for (nact = 0;  nact < atmos.Nactiveatom;  nact++) {
    atom = atmos.activeatoms[nact];

    writeAtom(atom);
    writePopulations(atom);
    writeRadRate(atom);
    writeCollisionRate(atom);
    writeDamping(atom);
  } 
  for (nact = 0;  nact < atmos.Nactivemol;  nact++) {
    molecule = atmos.activemols[nact];
    writeMolPops(molecule);
  }

  writeOpacity();

  getCPU(1, TIME_POLL, "Write output");
  printTotalCPU();
}