/[svn]/libgig/trunk/src/gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gig.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3913 by schoenebeck, Fri Jun 4 11:28:11 2021 UTC revision 3924 by schoenebeck, Mon Jun 14 12:07:47 2021 UTC
# Line 3498  namespace { Line 3498  namespace {
3498          RIFF::List* _3prg = rgn->GetSubList(LIST_TYPE_3PRG);          RIFF::List* _3prg = rgn->GetSubList(LIST_TYPE_3PRG);
3499          if (_3prg) {          if (_3prg) {
3500              int dimensionRegionNr = 0;              int dimensionRegionNr = 0;
3501              RIFF::List* _3ewl = _3prg->GetFirstSubList();              size_t i = 0;
3502              while (_3ewl) {              for (RIFF::List* _3ewl = _3prg->GetSubListAt(i); _3ewl;
3503                     _3ewl = _3prg->GetSubListAt(++i))
3504                {
3505                  if (_3ewl->GetListType() == LIST_TYPE_3EWL) {                  if (_3ewl->GetListType() == LIST_TYPE_3EWL) {
3506                      pDimensionRegions[dimensionRegionNr] = new DimensionRegion(this, _3ewl);                      pDimensionRegions[dimensionRegionNr] = new DimensionRegion(this, _3ewl);
3507                      dimensionRegionNr++;                      dimensionRegionNr++;
3508                  }                  }
                 _3ewl = _3prg->GetNextSubList();  
3509              }              }
3510              if (dimensionRegionNr == 0) throw gig::Exception("No dimension region found.");              if (dimensionRegionNr == 0) throw gig::Exception("No dimension region found.");
3511          }          }
# Line 4906  namespace { Line 4907  namespace {
4907          pScripts = new std::list<Script*>;          pScripts = new std::list<Script*>;
4908          if (!pList) return;          if (!pList) return;
4909    
4910          for (RIFF::Chunk* ck = pList->GetFirstSubChunk(); ck;          size_t i = 0;
4911               ck = pList->GetNextSubChunk())          for (RIFF::Chunk* ck = pList->GetSubChunkAt(i); ck;
4912                 ck = pList->GetSubChunkAt(++i))
4913          {          {
4914              if (ck->GetChunkID() == CHUNK_ID_SCRI) {              if (ck->GetChunkID() == CHUNK_ID_SCRI) {
4915                  pScripts->push_back(new Script(this, ck));                  pScripts->push_back(new Script(this, ck));
# Line 4987  namespace { Line 4989  namespace {
4989              if (!pRegions) pRegions = new RegionList;              if (!pRegions) pRegions = new RegionList;
4990              RIFF::List* lrgn = insList->GetSubList(LIST_TYPE_LRGN);              RIFF::List* lrgn = insList->GetSubList(LIST_TYPE_LRGN);
4991              if (lrgn) {              if (lrgn) {
4992                  RIFF::List* rgn = lrgn->GetFirstSubList();                  size_t i = 0;
4993                  while (rgn) {                  for (RIFF::List* rgn = lrgn->GetSubListAt(i); rgn;
4994                         rgn = lrgn->GetSubListAt(++i))
4995                    {
4996                      if (rgn->GetListType() == LIST_TYPE_RGN) {                      if (rgn->GetListType() == LIST_TYPE_RGN) {
4997                          if (pProgress)                          if (pProgress)
4998                              __notify_progress(pProgress, (float) pRegions->size() / (float) Regions);                              __notify_progress(pProgress, (float) pRegions->size() / (float) Regions);
4999                          pRegions->push_back(new Region(this, rgn));                          pRegions->push_back(new Region(this, rgn));
5000                      }                      }
                     rgn = lrgn->GetNextSubList();  
5001                  }                  }
5002                  // Creating Region Key Table for fast lookup                  // Creating Region Key Table for fast lookup
5003                  UpdateRegionKeyTable();                  UpdateRegionKeyTable();
# Line 6083  namespace { Line 6086  namespace {
6086    
6087          if (!pNameChunk && pFile->pVersion && pFile->pVersion->major > 2) {          if (!pNameChunk && pFile->pVersion && pFile->pVersion->major > 2) {
6088              // v3 has a fixed list of 128 strings, find a free one              // v3 has a fixed list of 128 strings, find a free one
6089              for (RIFF::Chunk* ck = _3gnl->GetFirstSubChunk() ; ck ; ck = _3gnl->GetNextSubChunk()) {              size_t i = 0;
6090                for (RIFF::Chunk* ck = _3gnl->GetSubChunkAt(i); ck; ck = _3gnl->GetSubChunkAt(++i)) {
6091                  if (strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) {                  if (strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) {
6092                      pNameChunk = ck;                      pNameChunk = ck;
6093                      break;                      break;
# Line 6443  namespace { Line 6447  namespace {
6447              if (wvpl) {              if (wvpl) {
6448                  file_offset_t wvplFileOffset = wvpl->GetFilePos() -                  file_offset_t wvplFileOffset = wvpl->GetFilePos() -
6449                                                 wvpl->GetPos(); // should be zero, but just to be sure                                                 wvpl->GetPos(); // should be zero, but just to be sure
6450                  RIFF::List* wave = wvpl->GetFirstSubList();                  size_t i = 0;
6451                  while (wave) {                  for (RIFF::List* wave = wvpl->GetSubListAt(i); wave;
6452                         wave = wvpl->GetSubListAt(++i))
6453                    {
6454                      if (wave->GetListType() == LIST_TYPE_WAVE) {                      if (wave->GetListType() == LIST_TYPE_WAVE) {
6455                          // notify current progress                          // notify current progress
6456                          if (pProgress) {                          if (pProgress) {
# Line 6457  namespace { Line 6463  namespace {
6463    
6464                          iSampleIndex++;                          iSampleIndex++;
6465                      }                      }
                     wave = wvpl->GetNextSubList();  
6466                  }                  }
6467              }              }
6468          }          }
# Line 6690  namespace { Line 6695  namespace {
6695          RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);          RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);
6696          if (lstInstruments) {          if (lstInstruments) {
6697              int iInstrumentIndex = 0;              int iInstrumentIndex = 0;
6698              RIFF::List* lstInstr = lstInstruments->GetFirstSubList();              size_t i = 0;
6699              while (lstInstr) {              for (RIFF::List* lstInstr = lstInstruments->GetSubListAt(i);
6700                     lstInstr; lstInstr = lstInstruments->GetSubListAt(++i))
6701                {
6702                  if (lstInstr->GetListType() == LIST_TYPE_INS) {                  if (lstInstr->GetListType() == LIST_TYPE_INS) {
6703                      if (pProgress) {                      if (pProgress) {
6704                          // notify current progress                          // notify current progress
# Line 6709  namespace { Line 6716  namespace {
6716    
6717                      iInstrumentIndex++;                      iInstrumentIndex++;
6718                  }                  }
                 lstInstr = lstInstruments->GetNextSubList();  
6719              }              }
6720              if (pProgress)              if (pProgress)
6721                  __notify_progress(pProgress, 1.0); // notify done                  __notify_progress(pProgress, 1.0); // notify done
# Line 6975  namespace { Line 6981  namespace {
6981          if (lst3gri) {          if (lst3gri) {
6982              RIFF::List* lst3gnl = lst3gri->GetSubList(LIST_TYPE_3GNL);              RIFF::List* lst3gnl = lst3gri->GetSubList(LIST_TYPE_3GNL);
6983              if (lst3gnl) {              if (lst3gnl) {
6984                  RIFF::Chunk* ck = lst3gnl->GetFirstSubChunk();                  size_t i = 0;
6985                  while (ck) {                  for (RIFF::Chunk* ck = lst3gnl->GetSubChunkAt(i); ck;
6986                         ck = lst3gnl->GetSubChunkAt(++i))
6987                    {
6988                      if (ck->GetChunkID() == CHUNK_ID_3GNM) {                      if (ck->GetChunkID() == CHUNK_ID_3GNM) {
6989                          if (pVersion && pVersion->major > 2 &&                          if (pVersion && pVersion->major > 2 &&
6990                              strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) break;                              strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) break;
6991    
6992                          pGroups->push_back(new Group(this, ck));                          pGroups->push_back(new Group(this, ck));
6993                      }                      }
                     ck = lst3gnl->GetNextSubChunk();  
6994                  }                  }
6995              }              }
6996          }          }
# Line 7073  namespace { Line 7080  namespace {
7080          pScriptGroups = new std::list<ScriptGroup*>;          pScriptGroups = new std::list<ScriptGroup*>;
7081          RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS);          RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS);
7082          if (lstLS) {          if (lstLS) {
7083              for (RIFF::List* lst = lstLS->GetFirstSubList(); lst;              size_t i = 0;
7084                   lst = lstLS->GetNextSubList())              for (RIFF::List* lst = lstLS->GetSubListAt(i); lst;
7085                     lst = lstLS->GetSubListAt(++i))
7086              {              {
7087                  if (lst->GetListType() == LIST_TYPE_RTIS) {                  if (lst->GetListType() == LIST_TYPE_RTIS) {
7088                      pScriptGroups->push_back(new ScriptGroup(this, lst));                      pScriptGroups->push_back(new ScriptGroup(this, lst));
# Line 7135  namespace { Line 7143  namespace {
7143              // INFO was added by Resource::UpdateChunks - make sure it              // INFO was added by Resource::UpdateChunks - make sure it
7144              // is placed first in file              // is placed first in file
7145              RIFF::Chunk* info = pRIFF->GetSubList(LIST_TYPE_INFO);              RIFF::Chunk* info = pRIFF->GetSubList(LIST_TYPE_INFO);
7146              RIFF::Chunk* first = pRIFF->GetFirstSubChunk();              RIFF::Chunk* first = pRIFF->GetSubChunkAt(0);
7147              if (first != info) {              if (first != info) {
7148                  pRIFF->MoveSubChunk(info, first);                  pRIFF->MoveSubChunk(info, first);
7149              }              }
# Line 7156  namespace { Line 7164  namespace {
7164              // v3: make sure the file has 128 3gnm chunks              // v3: make sure the file has 128 3gnm chunks
7165              // (before updating the Group chunks)              // (before updating the Group chunks)
7166              if (pVersion && pVersion->major > 2) {              if (pVersion && pVersion->major > 2) {
7167                  RIFF::Chunk* _3gnm = _3gnl->GetFirstSubChunk();                  size_t i = 0;
7168                  for (int i = 0 ; i < 128 ; i++) {                  for (RIFF::Chunk* _3gnm = _3gnl->GetSubChunkAt(i); i < 128;
7169                         _3gnm = _3gnl->GetSubChunkAt(++i))
7170                    {
7171                      // create 128 empty placeholder strings which will either                      // create 128 empty placeholder strings which will either
7172                      // be filled by Group::UpdateChunks below or left empty.                      // be filled by Group::UpdateChunks below or left empty.
7173                      ::SaveString(CHUNK_ID_3GNM, _3gnm, _3gnl, "", "", true, 64);                      ::SaveString(CHUNK_ID_3GNM, _3gnm, _3gnl, "", "", true, 64);
                     if (_3gnm) _3gnm = _3gnl->GetNextSubChunk();  
7174                  }                  }
7175              }              }
7176    

Legend:
Removed from v.3913  
changed lines
  Added in v.3924

  ViewVC Help
Powered by ViewVC