ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

directoryentry.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/myst3/directoryentry.h"
00024 #include "common/debug.h"
00025 
00026 namespace Myst3 {
00027 
00028 DirectoryEntry::DirectoryEntry(Archive *archive) :
00029     _archive(archive) {
00030     memset(_roomName, 0, sizeof(_roomName));
00031 }
00032 
00033 void DirectoryEntry::readFromStream(Common::SeekableReadStream &inStream, const char *room) {
00034     if (room == 0)
00035         inStream.read(_roomName, 4);
00036     else
00037         Common::strlcpy(_roomName, room, sizeof(_roomName));
00038 
00039     // The index is stored as a 24-bits number
00040     _index = inStream.readUint16LE();
00041     _index |= inStream.readByte() << 16;
00042 
00043     byte subItemCount = inStream.readByte();
00044     
00045     _subentries.clear();
00046     for (uint i = 0; i < subItemCount; i++) {
00047         DirectorySubEntry subEntry(_archive);
00048         subEntry.readFromStream(inStream);
00049         _subentries.push_back(subEntry);
00050     }
00051 }
00052 
00053 void DirectoryEntry::dumpToFiles(Common::SeekableReadStream &inStream) {
00054     for (uint i = 0; i < _subentries.size(); i++) {
00055         _subentries[i].dumpToFile(inStream, _roomName, _index);
00056     }
00057 }
00058 
00059 DirectorySubEntry *DirectoryEntry::getItemDescription(uint16 face, DirectorySubEntry::ResourceType type) {
00060     for (uint i = 0; i < _subentries.size(); i++) {
00061         if (_subentries[i].getFace() == face && _subentries[i].getType() == type) {
00062             return &_subentries[i];
00063         }
00064     }
00065     
00066     return 0;
00067 }
00068 
00069 DirectorySubEntryList DirectoryEntry::listItemsMatching(uint16 face, DirectorySubEntry::ResourceType type) {
00070     DirectorySubEntryList list;
00071 
00072     for (uint i = 0; i < _subentries.size(); i++) {
00073         if (_subentries[i].getFace() == face && _subentries[i].getType() == type) {
00074             list.push_back(&_subentries[i]);
00075         }
00076     }
00077 
00078     return list;
00079 }
00080 
00081 } // End of namespace Myst3


Generated on Sat Feb 16 2019 05:00:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge