/[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 3722 by schoenebeck, Wed Jan 22 15:37:09 2020 UTC revision 3723 by schoenebeck, Wed Jan 22 15:48:32 2020 UTC
# Line 4594  namespace { Line 4594  namespace {
4594              Name.resize(nameSize, ' ');              Name.resize(nameSize, ' ');
4595              for (int i = 0; i < nameSize; ++i)              for (int i = 0; i < nameSize; ++i)
4596                  Name[i] = ckScri->ReadUint8();                  Name[i] = ckScri->ReadUint8();
4597                // check if an uuid was already stored along with this script
4598                if (headerSize >= 6*sizeof(int32_t) + nameSize + 16) { // yes ...
4599                    for (uint i = 0; i < 16; ++i) {
4600                        Uuid[i] = ckScri->ReadUint8();
4601                    }
4602                } else { // no uuid yet, generate one now ...
4603                    GenerateUuid();
4604                }
4605              // to handle potential future extensions of the header              // to handle potential future extensions of the header
4606              ckScri->SetPos(sizeof(int32_t) + headerSize);              ckScri->SetPos(sizeof(int32_t) + headerSize);
4607              // read actual script data              // read actual script data
# Line 4608  namespace { Line 4616  namespace {
4616              Bypass   = false;              Bypass   = false;
4617              crc      = 0;              crc      = 0;
4618              Name     = "Unnamed Script";              Name     = "Unnamed Script";
4619                GenerateUuid();
4620          }          }
4621      }      }
4622    
# Line 4662  namespace { Line 4671  namespace {
4671          __calculateCRC(&data[0], data.size(), crc);          __calculateCRC(&data[0], data.size(), crc);
4672          __finalizeCRC(crc);          __finalizeCRC(crc);
4673          // make sure chunk exists and has the required size          // make sure chunk exists and has the required size
4674          const file_offset_t chunkSize = (file_offset_t) 7*sizeof(int32_t) + Name.size() + data.size();          const file_offset_t chunkSize =
4675                (file_offset_t) 7*sizeof(int32_t) + Name.size() + 16 + data.size();
4676          if (!pChunk) pChunk = pGroup->pList->AddSubChunk(CHUNK_ID_SCRI, chunkSize);          if (!pChunk) pChunk = pGroup->pList->AddSubChunk(CHUNK_ID_SCRI, chunkSize);
4677          else pChunk->Resize(chunkSize);          else pChunk->Resize(chunkSize);
4678          // fill the chunk data to be written to disk          // fill the chunk data to be written to disk
4679          uint8_t* pData = (uint8_t*) pChunk->LoadChunkData();          uint8_t* pData = (uint8_t*) pChunk->LoadChunkData();
4680          int pos = 0;          int pos = 0;
4681          store32(&pData[pos], uint32_t(6*sizeof(int32_t) + Name.size())); // total header size          store32(&pData[pos], uint32_t(6*sizeof(int32_t) + Name.size() + 16)); // total header size
4682          pos += sizeof(int32_t);          pos += sizeof(int32_t);
4683          store32(&pData[pos], Compression);          store32(&pData[pos], Compression);
4684          pos += sizeof(int32_t);          pos += sizeof(int32_t);
# Line 4684  namespace { Line 4694  namespace {
4694          pos += sizeof(int32_t);          pos += sizeof(int32_t);
4695          for (int i = 0; i < Name.size(); ++i, ++pos)          for (int i = 0; i < Name.size(); ++i, ++pos)
4696              pData[pos] = Name[i];              pData[pos] = Name[i];
4697            for (int i = 0; i < 16; ++i, ++pos)
4698                pData[pos] = Uuid[i];
4699          for (int i = 0; i < data.size(); ++i, ++pos)          for (int i = 0; i < data.size(); ++i, ++pos)
4700              pData[pos] = data[i];              pData[pos] = data[i];
4701      }      }
4702    
4703      /**      /**
4704         * Generate a new Universally Unique Identifier (UUID) for this script.
4705         */
4706        void Script::GenerateUuid() {
4707            DLS::dlsid_t dlsid;
4708            DLS::Resource::GenerateDLSID(&dlsid);
4709            Uuid[0]  = dlsid.ulData1       & 0xff;
4710            Uuid[1]  = dlsid.ulData1 >>  8 & 0xff;
4711            Uuid[2]  = dlsid.ulData1 >> 16 & 0xff;
4712            Uuid[3]  = dlsid.ulData1 >> 24 & 0xff;
4713            Uuid[4]  = dlsid.usData2       & 0xff;
4714            Uuid[5]  = dlsid.usData2 >>  8 & 0xff;
4715            Uuid[6]  = dlsid.usData3       & 0xff;
4716            Uuid[7]  = dlsid.usData3 >>  8 & 0xff;
4717            Uuid[8]  = dlsid.abData[0];
4718            Uuid[9]  = dlsid.abData[1];
4719            Uuid[10] = dlsid.abData[2];
4720            Uuid[11] = dlsid.abData[3];
4721            Uuid[12] = dlsid.abData[4];
4722            Uuid[13] = dlsid.abData[5];
4723            Uuid[14] = dlsid.abData[6];
4724            Uuid[15] = dlsid.abData[7];
4725        }
4726    
4727        /**
4728       * Move this script from its current ScriptGroup to another ScriptGroup       * Move this script from its current ScriptGroup to another ScriptGroup
4729       * given by @a pGroup.       * given by @a pGroup.
4730       *       *

Legend:
Removed from v.3722  
changed lines
  Added in v.3723

  ViewVC Help
Powered by ViewVC