aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-06-08 20:37:08 -0400
committerWillem Jan Palenstijn2015-06-10 07:12:25 +0200
commitdd116cfbf01b87c201249d98b2384e2671ff04bf (patch)
tree7a1c23ae5e588a52954f53bef77b1c0594f85aa9
parentb5f966ceb57b1d45f8c01b16f049fdea17f54a0d (diff)
downloadscummvm-rg350-dd116cfbf01b87c201249d98b2384e2671ff04bf.tar.gz
scummvm-rg350-dd116cfbf01b87c201249d98b2384e2671ff04bf.tar.bz2
scummvm-rg350-dd116cfbf01b87c201249d98b2384e2671ff04bf.zip
SHERLOCK: Add RT map data loading
-rw-r--r--engines/sherlock/tattoo/tattoo_map.cpp73
-rw-r--r--engines/sherlock/tattoo/tattoo_map.h18
2 files changed, 90 insertions, 1 deletions
diff --git a/engines/sherlock/tattoo/tattoo_map.cpp b/engines/sherlock/tattoo/tattoo_map.cpp
index ced7ed9a58..3a02d5b7ce 100644
--- a/engines/sherlock/tattoo/tattoo_map.cpp
+++ b/engines/sherlock/tattoo/tattoo_map.cpp
@@ -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
diff --git a/engines/sherlock/tattoo/tattoo_map.h b/engines/sherlock/tattoo/tattoo_map.h
index 750cd90c3b..b0c1a3fbc0 100644
--- a/engines/sherlock/tattoo/tattoo_map.h
+++ b/engines/sherlock/tattoo/tattoo_map.h
@@ -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() {}
/**