aboutsummaryrefslogtreecommitdiff
path: root/engines/sludge
diff options
context:
space:
mode:
authoryinsimei2017-07-11 00:02:46 +0200
committerEugene Sandulenko2017-07-13 18:27:45 +0200
commit38262ad6301953b373e3ef4341c2d1050bcd6981 (patch)
treea8baaddcb0fd263b73bd2fa2eb0969dd1d79e1a2 /engines/sludge
parent8f2a177cef73403ec65cac8430b3a0cae0249d37 (diff)
downloadscummvm-rg350-38262ad6301953b373e3ef4341c2d1050bcd6981.tar.gz
scummvm-rg350-38262ad6301953b373e3ef4341c2d1050bcd6981.tar.bz2
scummvm-rg350-38262ad6301953b373e3ef4341c2d1050bcd6981.zip
SLUDGE: use write/readFloatLB instead of Sludge get/putFloat
Diffstat (limited to 'engines/sludge')
-rw-r--r--engines/sludge/loadsave.cpp8
-rw-r--r--engines/sludge/moreio.cpp42
-rw-r--r--engines/sludge/moreio.h6
-rw-r--r--engines/sludge/objtypes.cpp4
-rw-r--r--engines/sludge/people.cpp16
-rw-r--r--engines/sludge/sludger.cpp4
-rw-r--r--engines/sludge/talk.cpp4
7 files changed, 19 insertions, 65 deletions
diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp
index d1fd187c92..e735d60049 100644
--- a/engines/sludge/loadsave.cpp
+++ b/engines/sludge/loadsave.cpp
@@ -418,7 +418,7 @@ bool saveGame(char *fname) {
// Save backdrop
fp->writeUint16BE(cameraX);
fp->writeUint16BE(cameraY);
- putFloat(cameraZoom, fp);
+ fp->writeFloatLE(cameraZoom);
fp->writeByte(brightnessLevel);
saveHSI(fp);
@@ -604,7 +604,7 @@ bool loadGame(char *fname) {
int camerY = fp->readUint16BE();
float camerZ;
if (ssgVersion >= VERSION(2, 0)) {
- camerZ = getFloat(fp);
+ camerZ = fp->readFloatLE();
} else {
camerZ = 1.0;
}
@@ -672,8 +672,8 @@ bool loadGame(char *fname) {
if (ssgVersion < VERSION(2, 0)) {
// aaLoad
fp->readByte();
- getFloat(fp);
- getFloat(fp);
+ fp->readFloatLE();
+ fp->readFloatLE();
}
blur_loadSettings(fp);
diff --git a/engines/sludge/moreio.cpp b/engines/sludge/moreio.cpp
index 874254c8ce..6635c3d3b7 100644
--- a/engines/sludge/moreio.cpp
+++ b/engines/sludge/moreio.cpp
@@ -29,13 +29,6 @@
#include "sludge/stringy.h"
#include "sludge/sludge.h"
-#if defined __unix__ && !(defined __APPLE__)
-#include <endian.h>
-#if __BYTE_ORDER == __BIG_ENDIAN
-#define __BIG_ENDIAN__
-#endif
-#endif
-
namespace Sludge {
bool allowAnyFilename = true;
@@ -62,41 +55,6 @@ char *readString(Common::SeekableReadStream *stream) {
return s;
}
-float floatSwap(float f) {
- union {
- float f;
- byte b[4];
- } dat1, dat2;
-
- dat1.f = f;
- dat2.b[0] = dat1.b[3];
- dat2.b[1] = dat1.b[2];
- dat2.b[2] = dat1.b[1];
- dat2.b[3] = dat1.b[0];
- return dat2.f;
-}
-
-float getFloat(Common::SeekableReadStream *stream) {
- float f;
- uint bytes_read = stream->read(&f, sizeof(float));
- if (bytes_read != sizeof(float) && stream->err()) {
- debug("Reading error in getFloat.\n");
- }
-
-#ifdef __BIG_ENDIAN__
- return floatSwap(f);
-#else
- return f;
-#endif
-}
-
-void putFloat(float f, Common::WriteStream *stream) {
-#ifdef __BIG_ENDIAN__
- f = floatSwap(f);
-#endif
- stream->write(&f, sizeof(float));
-}
-
char *encodeFilename(char *nameIn) {
if (!nameIn)
return NULL;
diff --git a/engines/sludge/moreio.h b/engines/sludge/moreio.h
index b22b76ac8c..94c82f2a3a 100644
--- a/engines/sludge/moreio.h
+++ b/engines/sludge/moreio.h
@@ -24,13 +24,9 @@
namespace Sludge {
-// Read
+// Read & Write
char *readString(Common::SeekableReadStream *stream);
-float getFloat(Common::SeekableReadStream *stream);
-
-// Write
void writeString(Common::String s, Common::WriteStream *stream);
-void putFloat(float f, Common::WriteStream *stream);
char *encodeFilename(char *nameIn);
char *decodeFilename(char *nameIn);
diff --git a/engines/sludge/objtypes.cpp b/engines/sludge/objtypes.cpp
index 8b660fc593..ebb9056cc8 100644
--- a/engines/sludge/objtypes.cpp
+++ b/engines/sludge/objtypes.cpp
@@ -69,8 +69,8 @@ objectType *loadObjectType(int i) {
if (gameVersion >= VERSION(1, 6)) {
// aaLoad
bigDataFile->readByte();
- getFloat(bigDataFile);
- getFloat(bigDataFile);
+ bigDataFile->readFloatLE();
+ bigDataFile->readFloatLE();
}
if (gameVersion >= VERSION(1, 4)) {
diff --git a/engines/sludge/people.cpp b/engines/sludge/people.cpp
index 276edf5d75..dca541bc91 100644
--- a/engines/sludge/people.cpp
+++ b/engines/sludge/people.cpp
@@ -1062,14 +1062,14 @@ bool savePeople(Common::WriteStream *stream) {
me = allPeople;
for (a = 0; a < countPeople; a++) {
- putFloat(me->x, stream);
- putFloat(me->y, stream);
+ stream->writeFloatLE(me->x);
+ stream->writeFloatLE(me->y);
saveCostume(me->myPersona, stream);
saveAnim(me->myAnim, stream);
stream->writeByte(me->myAnim == me->lastUsedAnim);
- putFloat(me->scale, stream);
+ stream->writeFloatLE(me->scale);
stream->writeUint16BE(me->extra);
stream->writeUint16BE(me->height);
@@ -1136,15 +1136,15 @@ bool loadPeople(Common::SeekableReadStream *stream) {
if (!checkNew(me->myAnim))
return false;
- me->x = getFloat(stream);
- me->y = getFloat(stream);
+ me->x = stream->readFloatLE();
+ me->y = stream->readFloatLE();
loadCostume(me->myPersona, stream);
loadAnim(me->myAnim, stream);
me->lastUsedAnim = stream->readByte() ? me->myAnim : NULL;
- me->scale = getFloat(stream);
+ me->scale = stream->readFloatLE();
me->extra = stream->readUint16BE();
me->height = stream->readUint16BE();
@@ -1194,8 +1194,8 @@ bool loadPeople(Common::SeekableReadStream *stream) {
if (ssgVersion < VERSION(2, 0)) {
// aaLoad
stream->readByte();
- getFloat(stream);
- getFloat(stream);
+ stream->readFloatLE();
+ stream->readFloatLE();
}
}
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 22e1926e31..a4ae34d627 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -256,8 +256,8 @@ bool initSludge(const char *filename) {
fp->readByte();
// aaLoad
fp->readByte();
- getFloat(fp);
- getFloat(fp);
+ fp->readFloatLE();
+ fp->readFloatLE();
}
char *checker = readString(fp);
diff --git a/engines/sludge/talk.cpp b/engines/sludge/talk.cpp
index 8f3dd02f20..12f6d8e151 100644
--- a/engines/sludge/talk.cpp
+++ b/engines/sludge/talk.cpp
@@ -216,7 +216,7 @@ void saveSpeech(speechStruct *sS, Common::WriteStream *stream) {
stream->writeByte(sS->talkCol.originalGreen);
stream->writeByte(sS->talkCol.originalBlue);
- putFloat(speechSpeed, stream);
+ stream->writeFloatLE(speechSpeed);
// Write y co-ordinate
stream->writeUint16BE(sS->speechY);
@@ -248,7 +248,7 @@ bool loadSpeech(speechStruct *sS, Common::SeekableReadStream *stream) {
byte b = stream->readByte();
setFontColour(sS->talkCol, r, g, b);
- speechSpeed = getFloat(stream);
+ speechSpeed = stream->readFloatLE();
// Read y co-ordinate
sS->speechY = stream->readUint16BE();