* added save Primitives

* modified detection of GF demo
* correction to GF game patch
This commit is contained in:
Pawel Kolodziejski 2009-06-23 07:14:53 +00:00
parent 5b8c499278
commit c035f6b6fd
8 changed files with 80 additions and 30 deletions

View File

@ -31,6 +31,7 @@ namespace Grim {
struct GrimGameDescription {
ADGameDescription desc;
int flags;
};
static const PlainGameDescriptor grimGames[] = {
@ -53,6 +54,7 @@ static const GrimGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO_NONE
},
0,
},
{
// Grim Fandago German version
@ -65,6 +67,7 @@ static const GrimGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO_NONE
},
0,
},
{
// Grim Fandago Spanish version
@ -77,6 +80,7 @@ static const GrimGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO_NONE
},
0,
},
{
// Grim Fandago Italian version
@ -89,6 +93,7 @@ static const GrimGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO_NONE
},
0,
},
{
// Grim Fandago English demo version
@ -98,13 +103,14 @@ static const GrimGameDescription gameDescriptions[] = {
AD_ENTRY1s("gfdemo01.lab", "755cdac083f7f751bec7506402278f1a", 29489930),
Common::EN_ANY,
Common::kPlatformPC,
ADGF_DEMO,
ADGF_NO_FLAGS,
GUIO_NONE
},
GF_DEMO,
},
{ AD_TABLE_END_MARKER }
{ AD_TABLE_END_MARKER, 0 }
};
static const GrimGameDescription fallbackGameDescriptions[] = {
@ -155,7 +161,7 @@ public:
bool GrimMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const GrimGameDescription *gd = (const GrimGameDescription *)desc;
if (gd) {
*engine = new GrimEngine(syst, gd);
*engine = new GrimEngine(syst, gd->flags);
}
return gd != 0;
}

View File

@ -221,18 +221,18 @@ const ControlDescriptor controls[] = {
GrimEngine *g_grim = NULL;
GfxBase *g_driver = NULL;
int g_imuseState = -1;
int g_flags = 0;
extern Common::StringList::const_iterator g_filesiter;
// hack for access current upated actor to allow access position of actor to sound costume component
Actor *g_currentUpdatedActor = NULL;
GrimEngine::GrimEngine(OSystem *syst, const GrimGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _currScene(NULL), _selectedActor(NULL) {
GrimEngine::GrimEngine(OSystem *syst, int gameFlags) :
Engine(syst), _currScene(NULL), _selectedActor(NULL) {
g_grim = this;
_gameFlags = gameFlags;
g_registry = new Registry();
g_resourceloader = NULL;
g_localizer = NULL;
@ -355,14 +355,14 @@ Common::Error GrimEngine::run() {
g_driver->setupScreen(640, 480, fullscreen);
Bitmap *splash_bm = NULL;
if (!(g_flags & GF_DEMO))
if (!(_gameFlags & GF_DEMO))
splash_bm = g_resourceloader->loadBitmap("splash.bm");
if (splash_bm)
splash_bm->ref();
g_driver->clearScreen();
if (!(g_flags & GF_DEMO))
if (!(_gameFlags & GF_DEMO))
splash_bm->draw();
g_driver->flipBuffer();
@ -1021,6 +1021,7 @@ void GrimEngine::savegameSave() {
saveFonts(_savedState);
saveTextObjects(_savedState);
savePrimitives(_savedState);
saveActors(_savedState);
//Chore_Save(_savedState);
@ -1105,6 +1106,23 @@ void GrimEngine::saveTextObjects(SaveGame *savedState) {
savedState->endSection();
}
void GrimEngine::savePrimitives(SaveGame *savedState) {
PointerId ptr;
savedState->beginSection('PRIM');
savedState->writeLESint32(_primitiveObjects.size());
for (PrimitiveListType::iterator i = _primitiveObjects.begin(); i != _primitiveObjects.end(); i++) {
PrimitiveObject *p = *i;
ptr = makeIdFromPointer(p);
savedState->writeLEUint32(ptr.low);
savedState->writeLEUint32(ptr.hi);
p->saveState(savedState);
}
savedState->endSection();
}
void GrimEngine::savegameCallback() {
lua_Object funcParam1;

View File

@ -59,8 +59,6 @@ struct GrimGameDescription;
typedef Common::HashMap<Common::String, const char *> StringPtrHashMap;
extern int g_flags;
#define GF_DEMO 1
struct ControlDescriptor {
@ -76,16 +74,16 @@ protected:
public:
GrimEngine(OSystem *syst, const GrimGameDescription *gameDesc);
GrimEngine(OSystem *syst, int gameFlags);
virtual ~GrimEngine();
int getGameFlags() { return _gameFlags; }
bool loadSaveDirectory(void);
void makeSystemMenu(void);
int modifyGameSpeed(int speedChange);
int getTimerDelay() const;
const GrimGameDescription *_gameDescription;
void setMode(int mode) { _mode = mode; }
int getMode() { return _mode; }
void setPreviousMode(int mode) { _previousMode = mode; }
@ -211,6 +209,7 @@ public:
void saveActors(SaveGame *savedState);
void saveFonts(SaveGame *savedState);
void saveTextObjects(SaveGame *savedState);
void savePrimitives(SaveGame *savedState);
void savegameCallback();
static void savegameReadStream(void *data, int32 size);
@ -263,6 +262,8 @@ private:
TextListType _textObjects;
PrimitiveListType _primitiveObjects;
Common::List<Font *> _fonts;
int _gameFlags;
};
extern GrimEngine *g_grim;

View File

@ -42,7 +42,7 @@ Localizer::Localizer() {
Common::File f;
const char *namesToTry[] = { "GRIM.TAB", "Grim.tab", "grim.tab" };
if (g_flags & GF_DEMO)
if (g_grim->getGameFlags() & GF_DEMO)
return;
for (unsigned i = 0; i < sizeof(namesToTry) / sizeof(namesToTry[0]); i++) {

View File

@ -25,6 +25,8 @@
#include "engines/grim/gfx_base.h"
#include "engines/grim/primitives.h"
#include "engines/grim/savegame.h"
#include "engines/grim/lua.h"
namespace Grim {
@ -40,6 +42,27 @@ PrimitiveObject::~PrimitiveObject() {
g_driver->destroyBitmap(_bitmap);
}
void PrimitiveObject::saveState(SaveGame *savedState) {
PointerId ptr;
savedState->writeLESint32(_type);
savedState->writeLEUint32(_color.red());
savedState->writeLEUint32(_color.green());
savedState->writeLEUint32(_color.blue());
savedState->writeLEUint32(_filled);
ptr = makeIdFromPointer(_bitmap);
savedState->writeLEUint32(ptr.low);
savedState->writeLEUint32(ptr.hi);
savedState->writeLEUint32(_p1.x);
savedState->writeLEUint32(_p1.y);
savedState->writeLEUint32(_p2.x);
savedState->writeLEUint32(_p2.y);
savedState->writeLEUint32(_p3.x);
savedState->writeLEUint32(_p3.y);
savedState->writeLEUint32(_p4.x);
savedState->writeLEUint32(_p4.y);
}
void PrimitiveObject::createRectangle(Common::Point p1, Common::Point p2, Color color, bool filled) {
_type = RECTANGLE;
_p1 = p1;

View File

@ -32,6 +32,8 @@
namespace Grim {
class SaveGame;
class PrimitiveObject {
public:
PrimitiveObject();
@ -59,6 +61,7 @@ public:
void draw();
bool isBitmap() { return _type == BITMAP; }
Bitmap *getBitmapHandle() { assert(_bitmap); return _bitmap; }
void saveState(SaveGame *savedState);
private:
Common::Point _p1, _p2, _p3, _p4;

View File

@ -51,13 +51,10 @@ ResourceLoader::ResourceLoader() {
const Common::String filename = (*x)->getName();
l = new Lab(filename.c_str());
if (l->isOpen()) {
if (filename == "005.lab")
if (filename.equalsIgnoreCase("data005.lab"))
_labs.push_front(l);
else {
if (filename == "gfdemo01.lab")
g_flags |= GF_DEMO;
else
_labs.push_back(l);
}
lab_counter++;
} else {
delete l;
@ -66,16 +63,18 @@ ResourceLoader::ResourceLoader() {
files.clear();
SearchMan.listMatchingMembers(files, "*.mus");
if (g_grim->getGameFlags() & GF_DEMO) {
SearchMan.listMatchingMembers(files, "*.mus");
for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
const Common::String filename = (*x)->getName();
l = new Lab(filename.c_str());
if (l->isOpen()) {
_labs.push_back(l);
lab_counter++;
} else {
delete l;
for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
const Common::String filename = (*x)->getName();
l = new Lab(filename.c_str());
if (l->isOpen()) {
_labs.push_back(l);
lab_counter++;
} else {
delete l;
}
}
}
}

View File

@ -46,7 +46,7 @@ Scene::Scene(const char *name, const char *buf, int len) :
_cmaps[i] = g_resourceloader->loadColormap(cmap_name);
}
if (g_flags & GF_DEMO) {
if (g_grim->getGameFlags() & GF_DEMO) {
ts.expectString("section: objectstates");
ts.scanString(" tot_objects %d", 1, &_numObjectStates);
char object_name[256];