| 32 | //----------------------------------------------------------------------------- |
| 33 | |
| 34 | SimObject* TamlBinaryReader::read( FileStream& stream ) |
| 35 | { |
| 36 | // Debug Profiling. |
| 37 | PROFILE_SCOPE(TamlBinaryReader_Read); |
| 38 | |
| 39 | // Read Taml signature. |
| 40 | StringTableEntry tamlSignature = stream.readSTString(); |
| 41 | |
| 42 | // Is the signature correct? |
| 43 | if ( tamlSignature != StringTable->insert( TAML_SIGNATURE ) ) |
| 44 | { |
| 45 | // Warn. |
| 46 | Con::warnf("Taml: Cannot read binary file as signature is incorrect '%s'.", tamlSignature ); |
| 47 | return NULL; |
| 48 | } |
| 49 | |
| 50 | // Read version Id. |
| 51 | U32 versionId; |
| 52 | stream.read( &versionId ); |
| 53 | |
| 54 | // Read compressed flag. |
| 55 | bool compressed; |
| 56 | stream.read( &compressed ); |
| 57 | |
| 58 | SimObject* pSimObject = NULL; |
| 59 | |
| 60 | // Is the stream compressed? |
| 61 | if ( compressed ) |
| 62 | { |
| 63 | // Yes, so attach zip stream. |
| 64 | ZipSubRStream zipStream; |
| 65 | zipStream.attachStream( &stream ); |
| 66 | |
| 67 | // Parse element. |
| 68 | pSimObject = parseElement( zipStream, versionId ); |
| 69 | |
| 70 | // Detach zip stream. |
| 71 | zipStream.detachStream(); |
| 72 | } |
| 73 | else |
| 74 | { |
| 75 | // No, so parse element. |
| 76 | pSimObject = parseElement( stream, versionId ); |
| 77 | } |
| 78 | |
| 79 | return pSimObject; |
| 80 | } |
| 81 | |
| 82 | //----------------------------------------------------------------------------- |
| 83 |
no test coverage detected