aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb/map.cpp
diff options
context:
space:
mode:
authorNipun Garg2019-07-06 20:58:26 +0530
committerEugene Sandulenko2019-09-03 17:17:14 +0200
commit6f472b60a65f01b250dc5c18d3209d4e555cc0bf (patch)
treebced4c49c5ee84e48c66ec4fe50734c78f1698ea /engines/hdb/map.cpp
parent2eb9bdfee86c5687e7cdc4e588a8c00764ab98fa (diff)
downloadscummvm-rg350-6f472b60a65f01b250dc5c18d3209d4e555cc0bf.tar.gz
scummvm-rg350-6f472b60a65f01b250dc5c18d3209d4e555cc0bf.tar.bz2
scummvm-rg350-6f472b60a65f01b250dc5c18d3209d4e555cc0bf.zip
HDB: Fix Endian reading issues
Diffstat (limited to 'engines/hdb/map.cpp')
-rw-r--r--engines/hdb/map.cpp45
1 files changed, 31 insertions, 14 deletions
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index b6e6774665..7f0c418331 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -65,8 +65,11 @@ void Map::save(Common::OutSaveFile *out) {
// Save out all Level2 Gratings and AnimCycle
out->writeSint32LE(_numGratings);
- for (i = 0; i < _numGratings; i++)
- out->write(_gratings[i], sizeof(_gratings[0]));
+ for (i = 0; i < _numGratings; i++) {
+ out->writeUint16LE(_gratings[i]->x);
+ out->writeUint16LE(_gratings[i]->y);
+ out->writeUint16LE(_gratings[i]->tile);
+ }
out->writeSint32LE(_animCycle);
@@ -104,11 +107,16 @@ void Map::save(Common::OutSaveFile *out) {
}
// save map data
- out->write(_background, sizeof(int32) * _width * _height);
- out->write(_foreground, sizeof(int32) * _width * _height);
- out->write(_mapExplosions, sizeof(byte) * _width * _height);
- out->write(_mapExpBarrels, sizeof(byte) * _width * _height);
- out->write(_mapLaserBeams, sizeof(byte) * _width * _height);
+ for (i = 0; i < _width * _height; i++)
+ out->writeSint32LE(_background[i]);
+ for (i = 0; i < _width * _height; i++)
+ out->writeSint32LE(_foreground[i]);
+ for (i = 0; i < _width * _height; i++)
+ out->writeByte(_mapExplosions[i]);
+ for (i = 0; i < _width * _height; i++)
+ out->writeByte(_mapExpBarrels[i]);
+ for (i = 0; i < _width * _height; i++)
+ out->writeByte(_mapLaserBeams[i]);
}
void Map::loadSaveFile(Common::InSaveFile *in) {
@@ -129,8 +137,11 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
// Load All level2 gratings and animCycle
_numGratings = in->readSint32LE();
- for (i = 0; i < _numGratings; i++)
- in->read(_gratings[i], sizeof(_gratings[0]));
+ for (i = 0; i < _numGratings; i++) {
+ _gratings[i]->x = in->readUint16LE();
+ _gratings[i]->y = in->readUint16LE();
+ _gratings[i]->tile = in->readUint16LE();
+ }
_animCycle = in->readSint32LE();
@@ -168,11 +179,17 @@ void Map::loadSaveFile(Common::InSaveFile *in) {
}
// load map data
- in->read(_background, sizeof(int32) * _width * _height);
- in->read(_foreground, sizeof(int32) * _width * _height);
- in->read(_mapExplosions, sizeof(byte) * _width * _height);
- in->read(_mapExpBarrels, sizeof(byte) * _width * _height);
- in->read(_mapLaserBeams, sizeof(byte) * _width * _height);
+
+ for (i = 0; i < _width * _height; i++)
+ _background[i] = in->readSint32LE();
+ for (i = 0; i < _width * _height; i++)
+ _foreground[i] = in->readSint32LE();
+ for (i = 0; i < _width * _height; i++)
+ _mapExplosions[i] = in->readByte();
+ for (i = 0; i < _width * _height; i++)
+ _mapExpBarrels[i] = in->readByte();
+ for (i = 0; i < _width * _height; i++)
+ _mapLaserBeams[i] = in->readByte();
}
int Map::loadTiles() {