Beispiel #1
0
ZFileSectorLoader::~ZFileSectorLoader()
{
  if (WorkingEmptySector)
  {
    delete WorkingEmptySector;
    WorkingEmptySector = 0;
  }
  if (WorkingFullSector)
  {
    delete WorkingFullSector;
    WorkingFullSector = 0;
  }

  ZVoxelSector * Sector;

  if (ReadySectorList)
  {
    while (( Sector = ReadySectorList->PullFromList() ))
    {
      if (COMPILEOPTION_ALLOWSAVE) Sector->Save(UniverseNum);
      delete Sector;
    }
    delete ReadySectorList;
    ReadySectorList = 0;
  }
  if (EjectedSectorList)
  {
    EjectedSectorList->FreeRemainingContent();
    delete EjectedSectorList;
    EjectedSectorList = 0;
  }
  UniverseNum = 0;
}
Beispiel #2
0
void ZFileSectorLoader::MakeTasks()
{
  Long x,y,z;
  UByte Pri;

  // Sector Loading

  while (1)
  {
    if      (RequestList[5].PullFromList(x,y,z)) {Pri = 4; }
    else if (RequestList[4].PullFromList(x,y,z)) {Pri = 4; }
    else if (RequestList[3].PullFromList(x,y,z)) {Pri = 3; }
    else if (RequestList[2].PullFromList(x,y,z)) {Pri = 2; }
    else if (RequestList[1].PullFromList(x,y,z)) {Pri = 1; }
    else if (RequestList[0].PullFromList(x,y,z)) {Pri = 0; }
    else break;

    if (LoadSector(x,y,z) /*&& Pri<4*/) break;
  }

  // Sector Unloading

  ZVoxelSector * Sector;

  while ( (Sector = EjectedSectorList->PullFromList()) )
  {
    RequestTag.Remove(Sector->Pos_x, Sector->Pos_y, Sector->Pos_z);
    printf("Deleted : %lx, %lu L2 Start:%lu End:%lu nEntries:%lu\n", Sector,++debug_deletecount,EjectedSectorList->debug_getstart(),EjectedSectorList->debug_GetEnd(),EjectedSectorList->debug_GetnEntries() );
    if (COMPILEOPTION_ALLOWSAVE)
    {
#if COMPILEOPTION_SAVEONLYMODIFIED==1
      if (Sector->IsMustBeSaved())
#endif
      {
        Sector->Save(UniverseNum);
      }
    }
    //delete Sector;

     Sector->ReinitSector();
     SectorRecycling->PushToList(Sector);
  }

  return;

}
Beispiel #3
0
bool ZWorldConverter::WorldConvert(char const * Path)
{

  struct dirent * Entry;

  ZVoxelSector Sector;

  DIR * Directory;
  ZString FileSpec, FileName;

  if (!(Directory = opendir(Path))) { return(false); }
  while (( Entry = readdir(Directory) ))
  {
    FileName = Entry->d_name;
    FileSpec = Path; FileSpec << "/" << FileName;
    // printf("%s %x\n",Entry->d_name, Entry->d_type);
    if (Entry->d_type == DT_DIR)
    {


    }
    else if (Entry->d_type == DT_REG)
    {
      if (FileName.Lefts(6)=="Sector")
      {
        printf("Loading Sector %s\n", FileSpec.String);
        Sector.Load(0,FileSpec.String);
        SectorConvert(&Sector);
        Sector.Save(0,FileSpec.String);
      }
    }
  }

  closedir(Directory);
  return(true);
}