/*=========================================================================== * * Class CSrLStringSubrecord Method - bool ReadData (File); * *=========================================================================*/ bool CSrLStringSubrecord::ReadData (CSrFile& File) { bool Result; if (IsLoadLocal()) { Result = File.ReadDWord(m_StringID); SetIsStringLoaded(false); } else { m_String.Empty(); m_String.SetSize(m_RecordSize); if (m_RecordSize == 0) return (true); /* Read in the string data */ Result = File.Read((void *)(const SSCHAR *)m_String, m_RecordSize); /* Ensure the string/record is the correct size by checking that is nul terminated */ if (m_String.GetAt(m_RecordSize - 1) == NULL_CHAR) m_String.Truncate(m_RecordSize - 1); SetIsStringLoaded(true); } return (Result); }
bool CSrEpfdSubrecord::ReadData (CSrFile& File) { bool Result; switch (m_DataType) { case SP_EPFDTYPE_ONEFLOAT : SR_VERIFY_SUBRECORDSIZE(SR_EPFD01_SUBRECORD_SIZE) return File.Read(&m_Data01, SR_EPFD01_SUBRECORD_SIZE); case SP_EPFDTYPE_TWOFLOATS : SR_VERIFY_SUBRECORDSIZE(SR_EPFD02_SUBRECORD_SIZE) return File.Read(&m_Data02, SR_EPFD02_SUBRECORD_SIZE); case SP_EPFDTYPE_LEVELLIST : SR_VERIFY_SUBRECORDSIZE(SR_EPFD03_SUBRECORD_SIZE) return File.Read(&m_Data03, SR_EPFD03_SUBRECORD_SIZE); case SP_EPFDTYPE_ACTIVATE : SR_VERIFY_SUBRECORDSIZE(SR_EPFD04_SUBRECORD_SIZE) return File.Read(&m_Data04, SR_EPFD04_SUBRECORD_SIZE); case SP_EPFDTYPE_SPELL : SR_VERIFY_SUBRECORDSIZE(SR_EPFD05_SUBRECORD_SIZE) return File.Read(&m_Data05, SR_EPFD05_SUBRECORD_SIZE); case SP_EPFDTYPE_ZSTRING : m_Data06.String.SetSize(m_RecordSize + 2); m_Data06.String.SetSize(m_RecordSize); if (m_RecordSize == 0) return (true); Result = File.Read((void *)(const SSCHAR *)m_Data06.String, m_RecordSize); if (m_Data06.String.GetAt(m_RecordSize - 1) == NULL_CHAR) m_Data06.String.Truncate(m_RecordSize - 1); return Result; case SP_EPFDTYPE_LSTRING : if (m_Data07.IsLocalString) { m_Data07.IsLoaded = false; SR_VERIFY_SUBRECORDSIZE(4) return File.Read(&m_Data07.StringID, 4); } else {
/*=========================================================================== * * Class CSrLStringSubrecord Method - bool WriteData (File); * *=========================================================================*/ bool CSrLStringSubrecord::WriteData (CSrFile& File) { if (IsLoadLocal()) { return File.WriteDWord(m_StringID); } else { return File.Write((const SSCHAR *)m_String, m_String.GetLength() + 1); } }
bool CSrVmadSubrecord::ReadData (CSrFile& File) { delete m_pRawData; m_RawDataSize = m_RecordSize; m_pRawData = new byte[m_RawDataSize + 4]; if (m_RecordSize == 0) return true; if (!File.Read(m_pRawData, m_RecordSize)) return false; return ParseRawData(); }
/*=========================================================================== * * Class CSrStringSubrecord Method - bool ReadData (File); * *=========================================================================*/ bool CSrStringSubrecord::ReadData (CSrFile& File) { bool Result; /* Preallocate the string to the desired size */ m_String.Empty(); m_String.SetSize(m_RecordSize + 2); m_String.SetSize(m_RecordSize); if (m_RecordSize == 0) return (true); /* Read in the string data */ Result = File.Read((void *)(const SSCHAR *)m_String, m_RecordSize); /* Ensure the string/record is the correct size by checking that is nul terminated */ if (m_String.GetAt(m_RecordSize - 1) == NULL_CHAR) m_String.Truncate(m_RecordSize - 1); return (Result); }
/*=========================================================================== * * Function - bool ReadSrBaseHeader (File, Header); * * Helper function to read base header data for a group or record * from the current location in the given file. * *=========================================================================*/ bool ReadSrBaseHeader (CSrFile& File, srbaseheader_t& Header) { return File.Read(&Header, SR_BASEHEADER_SIZE); }
/*=========================================================================== * * Class CSrBsaFolder Method - bool ReadHeader (File); * *=========================================================================*/ bool CSrBsaFolder::ReadHeader (CSrFile& File) { return File.Read((char *)&m_Header, sizeof(m_Header)); }
/*=========================================================================== * * Class CSrBsaFolder Method - bool WriteHeader (File); * *=========================================================================*/ bool CSrBsaFolder::WriteHeader (CSrFile& File) { return File.Write((char *)&m_Header, sizeof(m_Header)); }
bool CSrVmadSubrecord::WriteData (CSrFile& File) { if (!CreateRawData()) return false; return File.Write(m_pRawData, m_RawDataSize); }
bool CSrArraySubrecord::ReadData (CSrFile& File) { return AddSrGeneralError("%08X: Cannot read an array of subrecords!", File.Tell()); }
/*=========================================================================== * * Function - bool WriteSrRecType (File, Name); * * Writes a 4-byte record type field returning false on any error. * *=========================================================================*/ bool WriteSrRecType (CSrFile& File, const srrectype_t Name) { return File.Write((void *)&Name, SR_RECTYPE_SIZE); }
/*=========================================================================== * * Function - bool ReadSrRecType (File, Name); * * Reads a 4-byte record type field returning false on any error. * *=========================================================================*/ bool ReadSrRecType (CSrFile& File, srrectype_t& Name) { return File.Read((void *)&Name, SR_RECTYPE_SIZE); }