Skip to content

Commit

Permalink
ENGINES: Remove some uses of g_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Jun 3, 2011
1 parent e364072 commit aec2ea9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
13 changes: 7 additions & 6 deletions engines/lastexpress/data/animation.cpp
Expand Up @@ -94,7 +94,7 @@ bool Animation::load(Common::SeekableReadStream *stream, int flag) {
}
_currentChunk = _chunks.begin();
_changed = false;
_startTime = g_engine->_system->getMillis();
_startTime = g_system->getMillis();

return true;
}
Expand All @@ -110,7 +110,7 @@ bool Animation::process() {
// - Re-implement to be closer to the original engine
// - Add support for subtitles
// - Use engine sound queue instead of our own appendable sound instance
int32 currentFrame = (g_engine->_system->getMillis() - _startTime) * 3 / 100;
int32 currentFrame = (g_system->getMillis() - _startTime) * 3 / 100;

// Process all chunks until the current frame
while (!_changed && _currentChunk != NULL && currentFrame > _currentChunk->frame && !hasEnded()) {
Expand Down Expand Up @@ -180,7 +180,7 @@ bool Animation::process() {

// Synchronize the audio by resetting the start time
if (_currentChunk->frame == 0)
_startTime = g_engine->_system->getMillis();
_startTime = g_system->getMillis();
break;

case kChunkTypeAudioEnd:
Expand Down Expand Up @@ -260,7 +260,8 @@ void Animation::processChunkAudio(Common::SeekableReadStream *in, const Chunk &c

// TODO: this method will probably go away and be integrated in the main loop
void Animation::play() {
while (!hasEnded() && !g_engine->getEventManager()->shouldQuit() && !g_engine->getEventManager()->shouldRTL()) {
Common::EventManager *eventMan = g_system->getEventManager();
while (!hasEnded() && !Engine::shouldQuit()) {
process();

if (_changed) {
Expand All @@ -283,11 +284,11 @@ void Animation::play() {
g_system->updateScreen();

//FIXME: implement subtitles
g_engine->_system->delayMillis(20);
g_system->delayMillis(20);

// Handle right-click to interrupt animations
Common::Event ev = Common::Event();
while (g_engine->getEventManager()->pollEvent(ev)) {
while (eventMan->pollEvent(ev)) {
if (ev.type == Common::EVENT_RBUTTONUP) {
// Stop audio
if (_audio)
Expand Down
2 changes: 1 addition & 1 deletion engines/lastexpress/debug.cpp
Expand Up @@ -865,7 +865,7 @@ bool Debugger::cmdBeetle(int argc, const char **argv) {
askForRedraw();
redrawScreen();

while (g_engine->getEventManager()->pollEvent(ev)) {
while (g_system->getEventManager()->pollEvent(ev)) {

switch (ev.type) {
default:
Expand Down
20 changes: 10 additions & 10 deletions engines/sci/engine/kfile.cpp
Expand Up @@ -105,7 +105,7 @@ reg_t file_open(EngineState *s, const Common::String &filename, int mode, bool u
Common::String wrappedName = unwrapFilename ? g_sci->wrapFilename(englishName) : englishName;
Common::SeekableReadStream *inFile = 0;
Common::WriteStream *outFile = 0;
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();

if (mode == _K_FILE_MODE_OPEN_OR_FAIL) {
// Try to open file, abort if not possible
Expand Down Expand Up @@ -349,7 +349,7 @@ reg_t kDeviceInfo(EngineState *s, int argc, reg_t *argv) {
if (findSavegame(saves, savegameId) != -1) {
// Confirmed that this id still lives...
Common::String filename = g_sci->getSavegameName(savegameId);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
saveFileMan->removeSavefile(filename);
}
break;
Expand Down Expand Up @@ -410,7 +410,7 @@ static bool _savegame_sort_byDate(const SavegameDesc &l, const SavegameDesc &r)

// Create a sorted array containing all found savedgames
static void listSavegames(Common::Array<SavegameDesc> &saves) {
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();

// Load all saves
Common::StringArray saveNames = saveFileMan->listSavefiles(g_sci->getSavegamePattern());
Expand Down Expand Up @@ -637,7 +637,7 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) {
s->r_acc = NULL_REG;

Common::String filename = g_sci->getSavegameName(savegameId);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
Common::OutSaveFile *out;

out = saveFileMan->openForSaving(filename);
Expand Down Expand Up @@ -705,7 +705,7 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) {
s->r_acc = TRUE_REG;
warning("Savegame ID %d not found", savegameId);
} else {
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
Common::String filename = g_sci->getSavegameName(savegameId);
Common::SeekableReadStream *in;

Expand Down Expand Up @@ -845,7 +845,7 @@ reg_t kFileIOWriteRaw(EngineState *s, int argc, reg_t *argv) {

reg_t kFileIOUnlink(EngineState *s, int argc, reg_t *argv) {
Common::String name = s->_segMan->getString(argv[0]);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
bool result;

// SQ4 floppy prepends /\ to the filenames
Expand Down Expand Up @@ -920,7 +920,7 @@ reg_t kFileIOSeek(EngineState *s, int argc, reg_t *argv) {
}

void DirSeeker::addAsVirtualFiles(Common::String title, Common::String fileMask) {
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
Common::StringArray foundFiles = saveFileMan->listSavefiles(fileMask);
if (!foundFiles.empty()) {
_files.push_back(title);
Expand Down Expand Up @@ -984,7 +984,7 @@ reg_t DirSeeker::firstFile(const Common::String &mask, reg_t buffer, SegManager
const Common::String wrappedMask = g_sci->wrapFilename(mask);

// Obtain a list of all files matching the given mask
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
_files = saveFileMan->listSavefiles(wrappedMask);
}

Expand Down Expand Up @@ -1043,7 +1043,7 @@ reg_t kFileIOExists(EngineState *s, int argc, reg_t *argv) {
exists = Common::File::exists(name);

// Check for a savegame with the name
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
if (!exists)
exists = !saveFileMan->listSavefiles(name).empty();

Expand Down Expand Up @@ -1083,7 +1083,7 @@ reg_t kFileIORename(EngineState *s, int argc, reg_t *argv) {

// SCI1.1 returns 0 on success and a DOS error code on fail. SCI32
// returns -1 on fail. We just return -1 for all versions.
if (g_engine->getSaveFileManager()->renameSavefile(oldName, newName))
if (g_sci->getSaveFileManager()->renameSavefile(oldName, newName))
return NULL_REG;
else
return SIGNAL_REG;
Expand Down

0 comments on commit aec2ea9

Please sign in to comment.