RCS file: /cvsroot/scummvm/scummvm/scumm/smush/chunk.cpp,v
retrieving revision 1.36
diff -u -d -r1.36 chunk.cpp
|
|
|
85 | 85 | return true; |
86 | 86 | } |
87 | 87 | |
88 | | FileChunk::FileChunk(const Common::String &name, int offset) |
89 | | : _name(name) { |
90 | | if (!g_scumm->openFile(_data, name.c_str())) |
| 88 | FileChunk::FileChunk(ScummFile *data, int offset) { |
| 89 | _data = data; |
| 90 | _deleteData = false; |
| 91 | |
| 92 | _data->seek(offset, seek_start); |
| 93 | _type = _data->readUint32BE(); |
| 94 | _size = _data->readUint32BE(); |
| 95 | _offset = _data->pos(); |
| 96 | _curPos = 0; |
| 97 | } |
| 98 | |
| 99 | FileChunk::FileChunk(const Common::String &name, int offset) { |
| 100 | _data = new ScummFile(); |
| 101 | _deleteData = true; |
| 102 | if (!g_scumm->openFile(*_data, name.c_str())) |
91 | 103 | error("FileChunk: Unable to open file %s", name.c_str()); |
92 | 104 | |
93 | | _data.seek(offset); |
94 | | _type = _data.readUint32BE(); |
95 | | _size = _data.readUint32BE(); |
96 | | _offset = _data.pos(); |
| 105 | _data->seek(offset, seek_start); |
| 106 | _type = _data->readUint32BE(); |
| 107 | _size = _data->readUint32BE(); |
| 108 | _offset = _data->pos(); |
97 | 109 | _curPos = 0; |
98 | 110 | } |
99 | 111 | |
100 | 112 | FileChunk::~FileChunk() { |
| 113 | if (_deleteData) |
| 114 | delete _data; |
101 | 115 | } |
102 | 116 | |
103 | 117 | Chunk *FileChunk::subBlock() { |
104 | | FileChunk *ptr = new FileChunk(_name, _offset + _curPos); |
105 | | _data.seek(_offset + _curPos + sizeof(Chunk::type) + sizeof(uint32)); |
| 118 | FileChunk *ptr = new FileChunk(_data, _offset + _curPos); |
| 119 | _data->seek(_offset + _curPos + sizeof(Chunk::type) + sizeof(uint32) + ptr->getSize()); |
106 | 120 | seek(sizeof(Chunk::type) + sizeof(uint32) + ptr->getSize()); |
107 | 121 | return ptr; |
108 | 122 | } |
… |
… |
|
111 | 125 | if (size <= 0 || (_curPos + size) > _size) |
112 | 126 | error("invalid buffer read request"); |
113 | 127 | |
114 | | // _data.seek(_offset + _curPos); |
115 | | _data.read(buffer, size); |
| 128 | _data->seek(_offset + _curPos); |
| 129 | _data->read(buffer, size); |
116 | 130 | _curPos += size; |
117 | 131 | return true; |
118 | 132 | } |
… |
… |
|
122 | 136 | } |
123 | 137 | |
124 | 138 | byte FileChunk::getByte() { |
125 | | // _data.seek(_offset + _curPos); |
| 139 | _data->seek(_offset + _curPos); |
126 | 140 | _curPos++; |
127 | 141 | |
128 | 142 | if (_curPos > _size) |
129 | 143 | error("invalid byte read request"); |
130 | 144 | |
131 | | return _data.readByte(); |
| 145 | return _data->readByte(); |
132 | 146 | } |
133 | 147 | |
134 | 148 | int16 FileChunk::getShort() { |
… |
… |
|
136 | 150 | } |
137 | 151 | |
138 | 152 | uint16 FileChunk::getWord() { |
139 | | // _data.seek(_offset + _curPos); |
| 153 | _data->seek(_offset + _curPos); |
140 | 154 | _curPos += 2; |
141 | 155 | |
142 | 156 | if (_curPos > _size) |
143 | 157 | error("invalid word read request"); |
144 | 158 | |
145 | | return _data.readUint16LE(); |
| 159 | return _data->readUint16LE(); |
146 | 160 | } |
147 | 161 | |
148 | 162 | uint32 FileChunk::getDword() { |
149 | | // _data.seek(_offset + _curPos); |
| 163 | _data->seek(_offset + _curPos); |
150 | 164 | _curPos += 4; |
151 | 165 | |
152 | 166 | if (_curPos > _size) |
153 | 167 | error("invalid dword read request"); |
154 | 168 | |
155 | | return _data.readUint32LE(); |
| 169 | return _data->readUint32LE(); |
156 | 170 | } |
157 | 171 | |
158 | 172 | MemoryChunk::MemoryChunk(byte *data) { |
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/chunk.h,v
retrieving revision 1.19
diff -u -d -r1.19 chunk.h
|
|
|
69 | 69 | |
70 | 70 | class FileChunk : public BaseChunk { |
71 | 71 | private: |
72 | | Common::String _name; |
73 | | ScummFile _data; |
| 72 | ScummFile *_data; |
| 73 | bool _deleteData; |
74 | 74 | uint32 _offset; |
75 | 75 | |
| 76 | FileChunk(ScummFile *data, int offset); |
76 | 77 | public: |
77 | 78 | FileChunk(const Common::String &name, int offset = 0); |
78 | 79 | virtual ~FileChunk(); |