SHERLOCK: Add RT map data loading

This commit is contained in:
Paul Gilbert 2015-06-08 20:37:08 -04:00 committed by Willem Jan Palenstijn
parent b5f966ceb5
commit dd116cfbf0
2 changed files with 90 additions and 1 deletions

View File

@ -21,16 +21,89 @@
*/
#include "sherlock/tattoo/tattoo_map.h"
#include "sherlock/sherlock.h"
namespace Sherlock {
namespace Tattoo {
void MapEntry::clear() {
_iconNum = -1;
_description = "";
}
/*-------------------------------------------------------------------------*/
TattooMap::TattooMap(SherlockEngine *vm) : Map(vm) {
loadData();
}
int TattooMap::show() {
// TODO
return 61;
}
void TattooMap::loadData() {
Resources &res = *_vm->_res;
char c;
Common::SeekableReadStream *stream = res.load("map.txt");
_data.resize(100);
for (uint idx = 0; idx < _data.size(); ++idx)
_data[idx].clear();
do
{
// Find the start of the number
do {
c = stream->readByte();
if (stream->pos() >= stream->size())
return;
} while (c < '0' || c > '9');
// Get the scene number
Common::String locStr;
locStr += c;
while ((c = stream->readByte()) != '.')
locStr += c;
MapEntry &mapEntry = _data[atoi(locStr.c_str()) - 1];
// Get the location name
while (stream->readByte() != '"')
;
while ((c = stream->readByte()) != '"')
mapEntry._description += c;
// Find the ( specifying the (X,Y) position of the Icon
while (stream->readByte() != '(')
;
// Get the X Position of the icon
Common::String numStr;
while ((c = stream->readByte()) != ',')
numStr += c;
mapEntry.x = atoi(numStr.c_str());
// Get the Y position of the icon
numStr = "";
while ((c = stream->readByte()) != ')')
numStr += c;
mapEntry.y = atoi(numStr.c_str());
// Find and get the location's icon number
while (stream->readByte() != '#')
;
Common::String iconStr;
while (stream->pos() < stream->size() && (c = stream->readByte()) != '\r')
iconStr += c;
mapEntry._iconNum = atoi(iconStr.c_str()) - 1;
} while (stream->pos() < stream->size());
}
} // End of namespace Tattoo
} // End of namespace Sherlock

View File

@ -32,9 +32,25 @@ class SherlockEngine;
namespace Tattoo {
struct MapEntry : Common::Point {
int _iconNum;
Common::String _description;
MapEntry() : Common::Point(), _iconNum(-1) {}
MapEntry(int posX, int posY, int iconNum) : Common::Point(posX, posY), _iconNum(iconNum) {}
void clear();
};
class TattooMap : public Map {
private:
Common::Array<MapEntry> _data;
/**
* Load data needed for the map
*/
void loadData();
public:
TattooMap(SherlockEngine *vm) : Map(vm) {}
TattooMap(SherlockEngine *vm);
virtual ~TattooMap() {}
/**