Skip to content

Commit

Permalink
SCUMM: Make all HE saves prepend the target name
Browse files Browse the repository at this point in the history
This makes HE follow the ScummVM convention of using the target name everywhere. It also fixes having more than one team in both soccer and football.

Loading old saves will still work and they will be tried if the newer save names are not found.
  • Loading branch information
Matthew Hoops committed Oct 5, 2013
1 parent 3f65a02 commit 3bfd422
Show file tree
Hide file tree
Showing 13 changed files with 325 additions and 215 deletions.
6 changes: 3 additions & 3 deletions engines/scumm/he/animation_he.cpp
Expand Up @@ -57,21 +57,21 @@ int MoviePlayer::getImageNum() {
return _wizResNum;
}

int MoviePlayer::load(const char *filename, int flags, int image) {
int MoviePlayer::load(const Common::String &filename, int flags, int image) {
if (_video->isVideoLoaded())
_video->close();

// Ensure that Bink will use our PixelFormat
_video->setDefaultHighColorFormat(g_system->getScreenFormat());

if (!_video->loadFile(filename)) {
warning("Failed to load video file %s", filename);
warning("Failed to load video file %s", filename.c_str());
return -1;
}

_video->start();

debug(1, "Playing video %s", filename);
debug(1, "Playing video %s", filename.c_str());

if (flags & 2)
_vm->_wiz->createWizEmptyImage(image, 0, 0, _video->getWidth(), _video->getHeight());
Expand Down
8 changes: 6 additions & 2 deletions engines/scumm/he/animation_he.h
Expand Up @@ -25,8 +25,12 @@

#include "audio/mixer.h"

namespace Common {
class String;
}

namespace Video {
class VideoDecoder;
class VideoDecoder;
}

namespace Scumm {
Expand All @@ -39,7 +43,7 @@ class MoviePlayer {
~MoviePlayer();

int getImageNum();
int load(const char *filename, int flags, int image = 0);
int load(const Common::String &filename, int flags, int image = 0);

void copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint pitch);
void handleNextFrame();
Expand Down
15 changes: 14 additions & 1 deletion engines/scumm/he/intern_he.h
Expand Up @@ -81,10 +81,23 @@ class ScummEngine_v60he : public ScummEngine_v6 {
int virtScreenSave(byte *dst, int x1, int y1, int x2, int y2);
void virtScreenLoad(int resIdx, int x1, int y1, int x2, int y2);

int convertFilePath(byte *dst, int dstSize);
virtual void decodeParseString(int a, int b);
void swapObjects(int object1, int object2);

Common::String convertFilePath(const byte *src);
Common::String convertSavePath(const byte *src);
Common::String convertSavePathOld(const byte *src);

Common::SeekableReadStream *openFileForReading(const byte *fileName);
Common::SeekableReadStream *openSaveFileForReading(const byte *fileName);
Common::WriteStream *openSaveFileForWriting(const byte *fileName);
Common::WriteStream *openSaveFileForAppending(const byte *fileName);
void deleteSaveFile(const byte *fileName);
void renameSaveFile(const byte *from, const byte *to);

Common::SeekableReadStream *openSaveFileForReading(int slot, bool compat, Common::String &fileName);
Common::WriteStream *openSaveFileForWriting(int slot, bool compat, Common::String &fileName);

/* HE version 60 script opcodes */
void o60_setState();
void o60_roomOps();
Expand Down
19 changes: 10 additions & 9 deletions engines/scumm/he/logic/football.cpp
Expand Up @@ -449,25 +449,26 @@ int LogicHEfootball2002::initScreenTranslations() {

int LogicHEfootball2002::getPlaybookFiles(int32 *args) {
// Get the pattern and then skip over the directory prefix ("*\" or "*:")
Common::String pattern = (const char *)_vm->getStringAddress(args[0] & ~0x33539000) + 2;
// Also prepend the target name
Common::String targetName = _vm->getTargetName();
Common::String basePattern = ((const char *)_vm->getStringAddress(args[0] & ~0x33539000) + 2);
Common::String pattern = targetName + '-' + basePattern;

// Prepare a buffer to hold the file names
char buffer[1000];
buffer[0] = 0;
Common::String output;

// Get the list of file names that match the pattern and iterate over it
Common::StringArray fileList = _vm->getSaveFileManager()->listSavefiles(pattern);

for (uint32 i = 0; i < fileList.size() && strlen(buffer) < 970; i++) {
for (uint32 i = 0; i < fileList.size(); i++) {
// Isolate the base part of the filename and concatenate it to our buffer
Common::String fileName = Common::String(fileList[i].c_str(), fileList[i].size() - (pattern.size() - 1));
strcat(buffer, fileName.c_str());
strcat(buffer, ">"); // names separated by '>'
Common::String fileName(fileList[i].c_str() + targetName.size() + 1, fileList[i].size() - (basePattern.size() - 1) - (targetName.size() + 1));
output += fileName + '>'; // names separated by '>'
}

// Now store the result in an array
int array = _vm->setupStringArray(strlen(buffer));
strcpy((char *)_vm->getStringAddress(array), buffer);
int array = _vm->setupStringArray(output.size());
strcpy((char *)_vm->getStringAddress(array), output.c_str());

// And store the array index in variable 108
writeScummVar(108, array);
Expand Down
7 changes: 3 additions & 4 deletions engines/scumm/he/script_v100he.cpp
Expand Up @@ -1642,7 +1642,7 @@ void ScummEngine_v100he::o100_roomOps() {

copyScriptString((byte *)buffer, sizeof(buffer));

_saveLoadFileName = (char *)buffer + convertFilePath(buffer, sizeof(buffer));
_saveLoadFileName = (char *)buffer;
debug(1, "o100_roomOps: case 137: filename %s", _saveLoadFileName.c_str());

_saveLoadFlag = pop();
Expand Down Expand Up @@ -2263,11 +2263,10 @@ void ScummEngine_v100he::o100_videoOps() {
if (_videoParams.flags == 0)
_videoParams.flags = 4;

const char *filename = (char *)_videoParams.filename + convertFilePath(_videoParams.filename, sizeof(_videoParams.filename));
if (_videoParams.flags == 2) {
VAR(119) = _moviePlay->load(filename, _videoParams.flags, _videoParams.wizResNum);
VAR(119) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
} else {
VAR(119) = _moviePlay->load(filename, _videoParams.flags);
VAR(119) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
}
} else if (_videoParams.status == 19) {
// Stop video
Expand Down

0 comments on commit 3bfd422

Please sign in to comment.