2015-10-08 06:02:34 +03:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on Labyrinth of Time code with assistance of
|
|
|
|
*
|
|
|
|
* Copyright (c) 1993 Terra Nova Development
|
|
|
|
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-11-30 01:03:14 +01:00
|
|
|
#include "lab/lab.h"
|
2015-12-08 21:10:54 +01:00
|
|
|
|
2015-12-08 21:19:41 +01:00
|
|
|
#include "lab/dispman.h"
|
2015-12-08 20:36:05 +01:00
|
|
|
#include "lab/music.h"
|
2015-12-08 21:47:36 +01:00
|
|
|
#include "lab/processroom.h"
|
2015-12-08 21:10:54 +01:00
|
|
|
#include "lab/resource.h"
|
2015-10-08 06:02:34 +03:00
|
|
|
|
|
|
|
namespace Lab {
|
|
|
|
|
2015-11-30 00:34:43 +01:00
|
|
|
Resource::Resource(LabEngine *vm) : _vm(vm) {
|
2015-10-08 06:02:34 +03:00
|
|
|
readStaticText();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Resource::readStaticText() {
|
2015-12-04 21:47:47 +02:00
|
|
|
Common::File *labTextFile = openDataFile("Lab:Rooms/LabText");
|
2015-10-08 06:02:34 +03:00
|
|
|
|
|
|
|
for (int i = 0; i < 48; i++)
|
2015-12-04 21:47:47 +02:00
|
|
|
_staticText[i] = labTextFile->readLine();
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-04 21:47:47 +02:00
|
|
|
delete labTextFile;
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TextFont *Resource::getFont(const char *fileName) {
|
2015-12-18 05:42:26 +02:00
|
|
|
// TODO: Add support for the font format of the Amiga version
|
2015-12-04 21:47:47 +02:00
|
|
|
Common::File *dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'));
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-16 16:11:06 +01:00
|
|
|
uint32 headerSize = 4 + 2 + 256 * 3 + 4;
|
2015-10-08 06:02:34 +03:00
|
|
|
uint32 fileSize = dataFile->size();
|
|
|
|
if (fileSize <= headerSize)
|
2015-12-16 16:11:06 +01:00
|
|
|
return nullptr;
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-11-30 01:17:05 +01:00
|
|
|
_vm->_music->updateMusic();
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-01 02:17:26 +02:00
|
|
|
TextFont *textfont = new TextFont();
|
2015-12-07 07:48:54 +01:00
|
|
|
textfont->_dataLength = fileSize - headerSize;
|
|
|
|
textfont->_height = dataFile->readUint16LE();
|
|
|
|
dataFile->read(textfont->_widths, 256);
|
2015-10-08 06:02:34 +03:00
|
|
|
for (int i = 0; i < 256; i++)
|
2015-12-07 07:48:54 +01:00
|
|
|
textfont->_offsets[i] = dataFile->readUint16LE();
|
2015-10-08 06:02:34 +03:00
|
|
|
dataFile->skip(4);
|
2015-12-07 07:48:54 +01:00
|
|
|
textfont->_data = new byte[textfont->_dataLength + 4];
|
|
|
|
dataFile->read(textfont->_data, textfont->_dataLength);
|
2015-10-08 06:02:34 +03:00
|
|
|
return textfont;
|
|
|
|
}
|
|
|
|
|
2015-12-19 02:12:42 +02:00
|
|
|
Common::String Resource::getText(const char *fileName) {
|
2015-12-04 21:47:47 +02:00
|
|
|
Common::File *dataFile = openDataFile(fileName);
|
2015-12-01 02:05:29 +02:00
|
|
|
|
2015-12-10 07:04:59 +01:00
|
|
|
_vm->_music->updateMusic();
|
2015-12-01 02:05:29 +02:00
|
|
|
|
2015-12-04 02:44:29 +02:00
|
|
|
uint32 count = dataFile->size();
|
2015-12-01 02:05:29 +02:00
|
|
|
byte *buffer = new byte[count];
|
|
|
|
byte *text = buffer;
|
|
|
|
dataFile->read(buffer, count);
|
|
|
|
|
2015-12-16 17:03:42 +01:00
|
|
|
while (text && (*text != '\0'))
|
2015-12-01 02:05:29 +02:00
|
|
|
*text++ -= (byte)95;
|
|
|
|
|
2015-12-04 21:47:47 +02:00
|
|
|
delete dataFile;
|
2015-12-19 02:12:42 +02:00
|
|
|
|
|
|
|
Common::String str = (char *)buffer;
|
|
|
|
delete[] buffer;
|
|
|
|
|
|
|
|
return str;
|
2015-12-01 02:05:29 +02:00
|
|
|
}
|
|
|
|
|
2015-10-08 06:02:34 +03:00
|
|
|
bool Resource::readRoomData(const char *fileName) {
|
2015-12-04 22:06:47 +02:00
|
|
|
Common::File *dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'));
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
_vm->_manyRooms = dataFile->readUint16LE();
|
|
|
|
_vm->_highestCondition = dataFile->readUint16LE();
|
2015-12-07 11:00:54 +02:00
|
|
|
_vm->_rooms = new RoomData[_vm->_manyRooms + 1];
|
2015-12-06 21:39:41 +01:00
|
|
|
memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
|
2015-12-13 19:31:40 +02:00
|
|
|
_vm->_rooms[i]._doors[NORTH] = dataFile->readUint16LE();
|
|
|
|
_vm->_rooms[i]._doors[SOUTH] = dataFile->readUint16LE();
|
|
|
|
_vm->_rooms[i]._doors[EAST] = dataFile->readUint16LE();
|
|
|
|
_vm->_rooms[i]._doors[WEST] = dataFile->readUint16LE();
|
2015-12-07 09:58:46 +02:00
|
|
|
_vm->_rooms[i]._transitionType = dataFile->readByte();
|
2015-12-06 21:39:41 +01:00
|
|
|
|
|
|
|
_vm->_rooms[i]._view[NORTH] = nullptr;
|
|
|
|
_vm->_rooms[i]._view[SOUTH] = nullptr;
|
|
|
|
_vm->_rooms[i]._view[EAST] = nullptr;
|
|
|
|
_vm->_rooms[i]._view[WEST] = nullptr;
|
|
|
|
_vm->_rooms[i]._rules = nullptr;
|
2015-12-19 02:12:42 +02:00
|
|
|
_vm->_rooms[i]._roomMsg = "";
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
delete dataFile;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-03 19:49:55 +01:00
|
|
|
InventoryData *Resource::readInventory(const char *fileName) {
|
2015-12-04 22:06:47 +02:00
|
|
|
Common::File *dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'));
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
_vm->_numInv = dataFile->readUint16LE();
|
2015-12-07 11:00:54 +02:00
|
|
|
InventoryData *inventory = new InventoryData[_vm->_numInv + 1];
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
for (uint16 i = 1; i <= _vm->_numInv; i++) {
|
2015-12-06 21:53:57 +01:00
|
|
|
inventory[i]._many = dataFile->readUint16LE();
|
|
|
|
inventory[i]._name = readString(dataFile);
|
|
|
|
inventory[i]._bitmapName = readString(dataFile);
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
delete dataFile;
|
2015-12-03 19:49:55 +01:00
|
|
|
|
|
|
|
return inventory;
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Resource::readViews(uint16 roomNum) {
|
|
|
|
Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
|
2015-12-04 22:06:47 +02:00
|
|
|
Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'));
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-19 02:12:42 +02:00
|
|
|
freeViews(roomNum);
|
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
_vm->_rooms[roomNum]._roomMsg = readString(dataFile);
|
|
|
|
_vm->_rooms[roomNum]._view[NORTH] = readView(dataFile);
|
|
|
|
_vm->_rooms[roomNum]._view[SOUTH] = readView(dataFile);
|
|
|
|
_vm->_rooms[roomNum]._view[EAST] = readView(dataFile);
|
|
|
|
_vm->_rooms[roomNum]._view[WEST] = readView(dataFile);
|
|
|
|
_vm->_rooms[roomNum]._rules = readRule(dataFile);
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-11-30 01:17:05 +01:00
|
|
|
_vm->_music->updateMusic();
|
2015-10-08 06:02:34 +03:00
|
|
|
|
|
|
|
delete dataFile;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-19 02:12:42 +02:00
|
|
|
void Resource::freeViews(uint16 roomNum) {
|
2015-12-19 12:42:22 +02:00
|
|
|
for (uint16 i = 0; i < 4; i++)
|
|
|
|
freeView(_vm->_rooms[roomNum]._view[i]);
|
2015-12-19 02:12:42 +02:00
|
|
|
|
2015-12-19 12:42:22 +02:00
|
|
|
freeRule(_vm->_rooms[roomNum]._rules);
|
2015-12-19 02:12:42 +02:00
|
|
|
}
|
|
|
|
|
2015-12-04 21:47:47 +02:00
|
|
|
Common::String Resource::translateFileName(Common::String filename) {
|
|
|
|
filename.toUppercase();
|
|
|
|
Common::String fileNameStrFinal;
|
|
|
|
|
2015-12-18 05:42:26 +02:00
|
|
|
if (filename.hasPrefix("P:") || filename.hasPrefix("F:")) {
|
2015-12-10 07:04:59 +01:00
|
|
|
if (_vm->_isHiRes)
|
2015-12-04 21:47:47 +02:00
|
|
|
fileNameStrFinal = "GAME/SPICT/";
|
|
|
|
else
|
|
|
|
fileNameStrFinal = "GAME/PICT/";
|
2015-12-18 05:42:26 +02:00
|
|
|
|
|
|
|
if (_vm->getPlatform() == Common::kPlatformAmiga) {
|
|
|
|
if (filename.hasPrefix("P:")) {
|
|
|
|
fileNameStrFinal = "PICT/";
|
|
|
|
} else {
|
|
|
|
fileNameStrFinal = "LABFONTS/";
|
|
|
|
filename += "T"; // all the Amiga fonts have a ".FONT" suffix
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (filename.hasPrefix("LAB:")) {
|
|
|
|
if (_vm->getPlatform() != Common::kPlatformAmiga)
|
|
|
|
fileNameStrFinal = "GAME/";
|
|
|
|
} else if (filename.hasPrefix("MUSIC:")) {
|
|
|
|
if (_vm->getPlatform() != Common::kPlatformAmiga)
|
|
|
|
fileNameStrFinal = "GAME/MUSIC/";
|
|
|
|
else
|
|
|
|
fileNameStrFinal = "MUSIC/";
|
|
|
|
}
|
2015-12-04 21:47:47 +02:00
|
|
|
|
|
|
|
if (filename.contains(':')) {
|
|
|
|
while (filename[0] != ':') {
|
|
|
|
filename.deleteChar(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
filename.deleteChar(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
fileNameStrFinal += filename;
|
|
|
|
|
|
|
|
return fileNameStrFinal;
|
|
|
|
}
|
|
|
|
|
2015-10-11 22:10:46 +03:00
|
|
|
Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
|
2015-10-08 06:02:34 +03:00
|
|
|
Common::File *dataFile = new Common::File();
|
|
|
|
dataFile->open(translateFileName(fileName));
|
2015-11-29 21:54:19 +01:00
|
|
|
if (!dataFile->isOpen())
|
2015-12-07 06:46:41 +01:00
|
|
|
error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName).c_str(), fileName);
|
2015-11-29 21:54:19 +01:00
|
|
|
|
2015-12-04 22:06:47 +02:00
|
|
|
if (fileHeader > 0) {
|
|
|
|
uint32 headerTag = dataFile->readUint32BE();
|
|
|
|
if (headerTag != fileHeader) {
|
|
|
|
dataFile->close();
|
2015-12-07 06:46:41 +01:00
|
|
|
error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName).c_str(), fileName, fileHeader, headerTag);
|
2015-12-04 22:06:47 +02:00
|
|
|
}
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return dataFile;
|
|
|
|
}
|
|
|
|
|
2015-12-19 02:12:42 +02:00
|
|
|
Common::String Resource::readString(Common::File *file) {
|
2015-10-08 06:02:34 +03:00
|
|
|
byte size = file->readByte();
|
|
|
|
if (!size)
|
2015-12-19 02:12:42 +02:00
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
Common::String str;
|
|
|
|
char c;
|
2015-10-08 06:02:34 +03:00
|
|
|
for (int i = 0; i < size; i++) {
|
2015-12-19 02:12:42 +02:00
|
|
|
c = file->readByte();
|
2015-10-08 13:41:29 +03:00
|
|
|
// Decrypt char
|
2015-12-19 02:12:42 +02:00
|
|
|
c = (i < size - 1) ? c - 95 : '\0';
|
|
|
|
str += c;
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 *Resource::readConditions(Common::File *file) {
|
|
|
|
int16 i = 0, cond;
|
2015-12-07 11:00:54 +02:00
|
|
|
int16 *list = new int16[25];
|
2015-10-08 06:02:34 +03:00
|
|
|
memset(list, 0, 25 * 2);
|
|
|
|
|
|
|
|
do {
|
|
|
|
cond = file->readUint16LE();
|
|
|
|
if (i < 25)
|
|
|
|
list[i++] = cond;
|
|
|
|
} while (cond);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2015-10-12 13:53:00 +03:00
|
|
|
RuleList *Resource::readRule(Common::File *file) {
|
2015-10-08 06:02:34 +03:00
|
|
|
char c;
|
2015-12-06 22:50:41 +02:00
|
|
|
RuleList *rules = new RuleList();
|
2015-10-08 06:02:34 +03:00
|
|
|
|
|
|
|
do {
|
|
|
|
c = file->readByte();
|
|
|
|
|
|
|
|
if (c == 1) {
|
2015-12-19 02:12:42 +02:00
|
|
|
Rule *rule = new Rule();
|
2015-12-06 21:53:57 +01:00
|
|
|
rule->_ruleType = file->readSint16LE();
|
|
|
|
rule->_param1 = file->readSint16LE();
|
|
|
|
rule->_param2 = file->readSint16LE();
|
|
|
|
rule->_condition = readConditions(file);
|
|
|
|
rule->_actionList = readAction(file);
|
2015-10-12 13:53:00 +03:00
|
|
|
rules->push_back(rule);
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
} while (c == 1);
|
|
|
|
|
2015-10-12 13:53:00 +03:00
|
|
|
return rules;
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
|
2015-12-19 12:42:22 +02:00
|
|
|
void Resource::freeRule(RuleList *ruleList) {
|
|
|
|
if (!ruleList)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (RuleList::iterator rule = ruleList->begin(); rule != ruleList->end(); ++rule) {
|
|
|
|
freeAction((*rule)->_actionList);
|
|
|
|
delete[](*rule)->_condition;
|
|
|
|
delete *rule;
|
|
|
|
*rule = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete ruleList;
|
|
|
|
ruleList = nullptr;
|
|
|
|
}
|
|
|
|
|
2015-10-08 06:02:34 +03:00
|
|
|
Action *Resource::readAction(Common::File *file) {
|
|
|
|
char c;
|
2015-12-16 16:11:06 +01:00
|
|
|
Action *action = nullptr;
|
|
|
|
Action *prev = nullptr;
|
|
|
|
Action *head = nullptr;
|
2015-10-08 06:02:34 +03:00
|
|
|
|
|
|
|
do {
|
|
|
|
c = file->readByte();
|
|
|
|
|
|
|
|
if (c == 1) {
|
2015-12-07 11:00:54 +02:00
|
|
|
action = new Action();
|
2015-10-08 13:41:29 +03:00
|
|
|
if (!head)
|
|
|
|
head = action;
|
2015-10-11 02:02:05 +03:00
|
|
|
if (prev)
|
2015-12-06 21:53:57 +01:00
|
|
|
prev->_nextAction = action;
|
|
|
|
action->_actionType = file->readSint16LE();
|
|
|
|
action->_param1 = file->readSint16LE();
|
|
|
|
action->_param2 = file->readSint16LE();
|
|
|
|
action->_param3 = file->readSint16LE();
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-06 21:53:57 +01:00
|
|
|
if (action->_actionType == SHOWMESSAGES) {
|
2015-12-14 14:20:22 +01:00
|
|
|
char **messages = (char **)malloc(action->_param1 * 4);
|
2015-12-19 02:12:42 +02:00
|
|
|
Common::String tmp;
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-19 02:12:42 +02:00
|
|
|
for (int i = 0; i < action->_param1; i++) {
|
|
|
|
tmp = readString(file);
|
2015-12-19 12:42:22 +02:00
|
|
|
messages[i] = (char *)malloc(tmp.size());
|
2015-12-19 02:12:42 +02:00
|
|
|
memcpy(messages[i], tmp.c_str(), tmp.size());
|
|
|
|
}
|
2015-10-08 06:02:34 +03:00
|
|
|
|
2015-12-06 21:53:57 +01:00
|
|
|
action->_data = (byte *)messages;
|
2015-10-08 06:02:34 +03:00
|
|
|
} else {
|
2015-12-19 02:12:42 +02:00
|
|
|
Common::String tmp;
|
|
|
|
tmp = readString(file);
|
2015-12-19 12:42:22 +02:00
|
|
|
action->_data = (byte *)malloc(tmp.size());
|
2015-12-19 02:12:42 +02:00
|
|
|
memcpy(action->_data, tmp.c_str(), tmp.size());
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
|
2015-12-16 16:11:06 +01:00
|
|
|
action->_nextAction = nullptr;
|
2015-10-11 02:02:05 +03:00
|
|
|
prev = action;
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
} while (c == 1);
|
|
|
|
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
2015-12-19 12:42:22 +02:00
|
|
|
void Resource::freeAction(Action *action) {
|
|
|
|
while (action) {
|
|
|
|
Action *nextAction = action->_nextAction;
|
|
|
|
if (action->_actionType == SHOWMESSAGES) {
|
|
|
|
char **messages = (char **)action->_data;
|
|
|
|
for (int i = 0; i < action->_param1; i++)
|
|
|
|
free(messages[i]);
|
|
|
|
free(messages);
|
|
|
|
} else
|
|
|
|
free(action->_data);
|
|
|
|
delete action;
|
|
|
|
action = nextAction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-08 06:02:34 +03:00
|
|
|
CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
|
|
|
|
char c;
|
2015-12-16 16:11:06 +01:00
|
|
|
CloseData *closeup = nullptr;
|
|
|
|
CloseData *prev = nullptr;
|
|
|
|
CloseData *head = nullptr;
|
2015-10-08 06:02:34 +03:00
|
|
|
|
|
|
|
do {
|
|
|
|
c = file->readByte();
|
|
|
|
|
|
|
|
if (c != '\0') {
|
2015-12-07 11:00:54 +02:00
|
|
|
closeup = new CloseData();
|
2015-10-08 13:41:29 +03:00
|
|
|
if (!head)
|
2015-10-11 02:02:05 +03:00
|
|
|
head = closeup;
|
|
|
|
if (prev)
|
2015-12-06 21:53:57 +01:00
|
|
|
prev->_nextCloseUp = closeup;
|
2015-12-09 11:22:41 +01:00
|
|
|
closeup->_x1 = file->readUint16LE();
|
|
|
|
closeup->_y1 = file->readUint16LE();
|
|
|
|
closeup->_x2 = file->readUint16LE();
|
|
|
|
closeup->_y2 = file->readUint16LE();
|
2015-12-06 21:53:57 +01:00
|
|
|
closeup->_closeUpType = file->readSint16LE();
|
|
|
|
closeup->_depth = depth;
|
|
|
|
closeup->_graphicName = readString(file);
|
|
|
|
closeup->_message = readString(file);
|
|
|
|
closeup->_subCloseUps = readCloseUps(depth + 1, file);
|
2015-12-16 16:11:06 +01:00
|
|
|
closeup->_nextCloseUp = nullptr;
|
2015-10-11 02:02:05 +03:00
|
|
|
prev = closeup;
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
} while (c != '\0');
|
2015-12-02 11:49:01 +01:00
|
|
|
|
2015-10-08 06:02:34 +03:00
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
2015-12-19 12:42:22 +02:00
|
|
|
void Resource::freeCloseUps(CloseData *closeUps) {
|
|
|
|
while (closeUps) {
|
|
|
|
CloseData *nextCloseUp = closeUps->_nextCloseUp;
|
|
|
|
freeCloseUps(closeUps->_subCloseUps);
|
|
|
|
delete closeUps;
|
|
|
|
closeUps = nextCloseUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-14 01:10:42 +03:00
|
|
|
ViewData *Resource::readView(Common::File *file) {
|
2015-10-08 06:02:34 +03:00
|
|
|
char c;
|
2015-12-16 16:11:06 +01:00
|
|
|
ViewData *view = nullptr;
|
|
|
|
ViewData *prev = nullptr;
|
|
|
|
ViewData *head = nullptr;
|
2015-10-08 06:02:34 +03:00
|
|
|
|
|
|
|
do {
|
|
|
|
c = file->readByte();
|
|
|
|
|
|
|
|
if (c == 1) {
|
2015-12-07 11:00:54 +02:00
|
|
|
view = new ViewData();
|
2015-10-08 13:41:29 +03:00
|
|
|
if (!head)
|
|
|
|
head = view;
|
2015-10-11 02:02:05 +03:00
|
|
|
if (prev)
|
2015-12-06 21:53:57 +01:00
|
|
|
prev->_nextCondition = view;
|
|
|
|
view->_condition = readConditions(file);
|
|
|
|
view->_graphicName = readString(file);
|
|
|
|
view->_closeUps = readCloseUps(0, file);
|
2015-12-16 16:11:06 +01:00
|
|
|
view->_nextCondition = nullptr;
|
2015-10-11 02:02:05 +03:00
|
|
|
prev = view;
|
2015-10-08 06:02:34 +03:00
|
|
|
}
|
|
|
|
} while (c == 1);
|
|
|
|
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
2015-12-19 12:42:22 +02:00
|
|
|
void Resource::freeView(ViewData *view) {
|
|
|
|
while (view) {
|
|
|
|
ViewData *nextView = view->_nextCondition;
|
|
|
|
delete[] view->_condition;
|
|
|
|
freeCloseUps(view->_closeUps);
|
|
|
|
delete view;
|
|
|
|
view = nextView;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-08 06:02:34 +03:00
|
|
|
} // End of namespace Lab
|