DREAMWEB: implemented openfile

This commit is contained in:
Vladimir 2011-06-08 01:25:26 +04:00 committed by Alyssa Milburn
parent 1494cdb295
commit 9a1575b9d5
2 changed files with 19 additions and 3 deletions

View File

@ -133,6 +133,15 @@ Common::Error DreamWebEngine::run() {
return Common::kNoError;
}
void DreamWebEngine::openFile(const Common::String &name) {
if (_file.isOpen()) {
_file.close();
}
if (!_file.open(name))
error("cannot open file %s", name.c_str());
}
} // End of namespace DreamWeb
@ -194,9 +203,11 @@ void openfile(Context &context) {
uint16 name_ptr = context.dx;
Common::String name;
uint8 c;
while((c = context.data.byte(name_ptr++)) != 0)
while((c = context.cs.byte(name_ptr++)) != 0)
name += (char)c;
debug(1, "opening file: %s", name.c_str());
context.cs.word(kHandle) = 1; //only one handle
context.flags._c = false;
}
void createfile(Context &context) {

View File

@ -26,10 +26,11 @@
#ifndef DREAMWEB_H
#define DREAMWEB_H
#include "common/scummsys.h"
#include "common/error.h"
#include "common/file.h"
#include "common/random.h"
#include "common/rect.h"
#include "common/error.h"
#include "common/scummsys.h"
#include "engines/engine.h"
#include "dreamweb/console.h"
@ -76,10 +77,14 @@ public:
//dreamgen public api:
uint8 randomNumber() { return _rnd.getRandomNumber(255); }
void openFile(const Common::String &name);
private:
const DreamWebGameDescription *_gameDescription;
Common::RandomSource _rnd;
Common::Point _mouse;
Common::File _file;
};
} // End of namespace DreamWeb