HOPKINS: Reverted to saving Breakout high scores in a separate file

This commit is contained in:
Paul Gilbert 2013-07-31 21:01:04 -04:00
parent b0ce97bccf
commit 07d8e5643b
12 changed files with 63 additions and 31 deletions

View File

@ -578,7 +578,11 @@ void ComputerManager::displayGamesSubMenu() {
* Load Highscore from file
*/
void ComputerManager::loadHiscore() {
const byte *ptr = _vm->_globals->_highScoreData;
byte *ptr = _vm->_globals->allocMemory(100);
memset(ptr, 0, 100);
if (_vm->_saveLoad->saveExists(_vm->targetName() + "-highscore.dat"))
_vm->_saveLoad->load(_vm->targetName() + "-highscore.dat", ptr);
for (int scoreIndex = 0; scoreIndex < 6; ++scoreIndex) {
_score[scoreIndex]._name = " ";
@ -600,6 +604,7 @@ void ComputerManager::loadHiscore() {
}
_lowestHiScore = atol(_score[5]._score.c_str());
_vm->_globals->freeMemory(ptr);
}
/**
@ -985,8 +990,8 @@ void ComputerManager::saveScore() {
}
}
byte *ptr = _vm->_globals->_highScoreData;
memset(ptr, 0, 99);
byte *ptr = _vm->_globals->allocMemory(100);
memset(ptr, 0, 100);
for (int scorePlaceIdx = 0; scorePlaceIdx <= 5; scorePlaceIdx++) {
int curBufPtr = 16 * scorePlaceIdx;
for (int namePos = 0; namePos < 6; namePos++) {
@ -1006,6 +1011,9 @@ void ComputerManager::saveScore() {
};
ptr[curBufPtr + 15] = 0;
}
_vm->_saveLoad->saveFile(_vm->targetName() + "-highscore.dat", ptr, 100);
_vm->_globals->freeMemory(ptr);
}
/**

View File

@ -56,6 +56,10 @@ bool HopkinsEngine::getIsDemo() const {
return _gameDescription->desc.flags & ADGF_DEMO;
}
Common::String HopkinsEngine::targetName() const {
return _targetName;
}
} // End of namespace Hopkins
static const PlainGameDescriptor hopkinsGames[] = {

View File

@ -70,8 +70,6 @@ Globals::Globals(HopkinsEngine *vm) {
for (int i = 0; i < 36; ++i)
_inventory[i] = 0;
Common::fill(&_highScoreData[0], &_highScoreData[100], 0);
// Initialize fields
_language = LANG_EN;

View File

@ -206,7 +206,6 @@ public:
Common::String _zoneFilename;
Common::String _textFilename;
byte *_levelSpriteBuf;
byte _highScoreData[100];
EventMode _eventMode;

View File

@ -164,6 +164,7 @@ public:
Common::Platform getPlatform() const;
uint16 getVersion() const;
bool getIsDemo() const;
Common::String targetName() const;
int getRandomNumber(int maxNumber);
Common::String generateSaveName(int slotNumber);

View File

@ -55,6 +55,13 @@ bool SaveLoadManager::save(const Common::String &file, const void *buf, size_t n
return false;
}
bool SaveLoadManager::saveExists(const Common::String &file) {
Common::InSaveFile *savefile = g_system->getSavefileManager()->openForLoading(file);
bool result = savefile != NULL;
delete savefile;
return result;
}
// Save File
bool SaveLoadManager::saveFile(const Common::String &file, const void *buf, size_t n) {
return save(file, buf, n);
@ -251,10 +258,6 @@ void SaveLoadManager::createThumbnail(Graphics::Surface *s) {
}
void SaveLoadManager::syncSavegameData(Common::Serializer &s, int version) {
if (version >= 3)
// Sync embedded Breakout game high score data
s.syncBytes(&_vm->_globals->_highScoreData[0], 100);
s.syncBytes(&_vm->_globals->_saveData->_data[0], 2050);
syncCharacterLocation(s, _vm->_globals->_saveData->_cloneHopkins);
syncCharacterLocation(s, _vm->_globals->_saveData->_realHopkins);

View File

@ -35,7 +35,7 @@ namespace Hopkins {
class HopkinsEngine;
#define HOPKINS_SAVEGAME_VERSION 3
#define HOPKINS_SAVEGAME_VERSION 2
struct hopkinsSavegameHeader {
uint8 _version;
@ -56,6 +56,7 @@ private:
public:
SaveLoadManager(HopkinsEngine *vm);
bool saveExists(const Common::String &file);
bool save(const Common::String &file, const void *buf, size_t n);
bool saveFile(const Common::String &file, const void *buf, size_t n);
void load(const Common::String &file, byte *buf);

View File

@ -2454,6 +2454,19 @@ void ScannerDialog::proc12(int visage, int stripFrameNum, int frameNum, int posX
}
}
/*--------------------------------------------------------------------------*/
FinePositionedObject::FinePositionedObject(): SceneObject() {
_x100 = _y100 = 0;
}
void FinePositionedObject::synchronize(Serializer &s) {
EventHandler::synchronize(s);
s.syncAsSint32LE(_x100);
s.syncAsSint32LE(_y100);
}
} // End of namespace Ringworld2
} // End of namespace TsAGE

View File

@ -514,6 +514,16 @@ public:
void proc12(int visage, int stripFrameNum, int frameNum, int posX, int posY);
};
class FinePositionedObject: public SceneObject {
public:
int _x100, _y100;
public:
FinePositionedObject();
virtual Common::String getClassName() { return "FinePositionedObject"; }
virtual void synchronize(Serializer &s);
};
} // End of namespace Ringworld2
} // End of namespace TsAGE

View File

@ -2312,19 +2312,6 @@ void Scene205::Action1::textLoop() {
/*--------------------------------------------------------------------------*/
Scene205::Object::Object(): SceneObject() {
_x100 = _y100 = 0;
}
void Scene205::Object::synchronize(Serializer &s) {
EventHandler::synchronize(s);
s.syncAsSint32LE(_x100);
s.syncAsSint32LE(_y100);
}
/*--------------------------------------------------------------------------*/
Scene205::Scene205(): SceneExt() {
_yp = 0;
_textIndex = 1;

View File

@ -273,13 +273,8 @@ class Scene205: public SceneExt {
};
/* Objects */
class Object: public SceneObject {
public:
int _x100, _y100;
public:
Object();
virtual void synchronize(Serializer &s);
class Object: public FinePositionedObject {
// TODO: More derived logic
};
private:
void setup();

View File

@ -39,6 +39,19 @@ namespace Ringworld2 {
using namespace TsAGE;
class Scene1000 : public SceneExt {
public:
SequenceManager _sequenceManager1;
SequenceManager _sequenceManager2;
SpeakerGameText _gameTextSpeaker;
public:
virtual void postInit(SceneObjectList *OwnerList = NULL);
virtual void remove();
virtual void signal();
virtual void dispatch();
};
class Scene1010 : public SceneExt {
public:
SequenceManager _sequenceManager;