aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gob/util.cpp25
-rw-r--r--engines/gob/util.h8
2 files changed, 29 insertions, 4 deletions
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 6d83745602..1add604ccb 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -20,6 +20,10 @@
*
*/
+#include "common/stream.h"
+#include "common/events.h"
+
+#include "graphics/palette.h"
#include "gob/gob.h"
#include "gob/util.h"
@@ -31,10 +35,6 @@
#include "gob/videoplayer.h"
#include "gob/sound/sound.h"
-#include "common/events.h"
-
-#include "graphics/palette.h"
-
namespace Gob {
Util::Util(GobEngine *vm) : _vm(vm) {
@@ -534,6 +534,23 @@ Common::String Util::setExtension(const Common::String &str, const Common::Strin
return str + ext;
}
+Common::String Util::readString(Common::SeekableReadStream &stream, int n) {
+ Common::String str;
+
+ char c;
+ while (n-- > 0) {
+ if ((c = stream.readByte()) == '\0')
+ break;
+
+ str += c;
+ }
+
+ if (n > 0)
+ stream.skip(n);
+
+ return str;
+}
+
/* NOT IMPLEMENTED */
void Util::checkJoystick() {
_vm->_global->_useJoystick = 0;
diff --git a/engines/gob/util.h b/engines/gob/util.h
index a6a689c1d2..7c1e44c0f6 100644
--- a/engines/gob/util.h
+++ b/engines/gob/util.h
@@ -23,8 +23,13 @@
#ifndef GOB_UTIL_H
#define GOB_UTIL_H
+#include "common/str.h"
#include "common/keyboard.h"
+namespace Common {
+ class SeekableReadStream;
+}
+
namespace Gob {
class GobEngine;
@@ -131,6 +136,9 @@ public:
static char *setExtension(char *str, const char *ext);
static Common::String setExtension(const Common::String &str, const Common::String &ext);
+ /** Read a constant-length string out of a stream. */
+ static Common::String readString(Common::SeekableReadStream &stream, int n);
+
Util(GobEngine *vm);
protected: