[Scummvm-cvs-logs] CVS: scummvm/scumm actor.h,1.5,1.6 imuse.cpp,1.94,1.95 saveload.cpp,1.27,1.28 saveload.h,1.4,1.5 scumm.h,1.72,1.73
Max Horn
fingolfin at users.sourceforge.net
Sun Dec 8 08:15:03 CET 2002
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv30040
Modified Files:
actor.h imuse.cpp saveload.cpp saveload.h scumm.h
Log Message:
Patch #650085: Make saveload system extensible
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- actor.h 10 Nov 2002 17:17:11 -0000 1.5
+++ actor.h 8 Dec 2002 16:14:28 -0000 1.6
@@ -101,7 +101,6 @@
byte frame;
byte walkbox;
- byte mask; // FIXME: This field is *NOT* used - remove next time save game format changes
byte animProgress, animSpeed;
int16 new_1, new_2;
uint16 talk_script, walk_script;
Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- imuse.cpp 7 Dec 2002 18:03:10 -0000 1.94
+++ imuse.cpp 8 Dec 2002 16:14:28 -0000 1.95
@@ -455,8 +455,8 @@
void fix_parts_after_load();
void fix_players_after_load(Scumm *scumm);
- static int saveReference(IMuseInternal *me, byte type, void *ref);
- static void *loadReference(IMuseInternal *me, byte type, int ref);
+ static int saveReference(void *me_ref, byte type, void *ref);
+ static void *loadReference(void *me_ref, byte type, int ref);
void lock();
void unlock();
@@ -3143,8 +3143,9 @@
TYPE_PLAYER = 2,
};
-int IMuseInternal::saveReference(IMuseInternal *me, byte type, void *ref)
+int IMuseInternal::saveReference(void *me_ref, byte type, void *ref)
{
+ IMuseInternal *me = (IMuseInternal *)me_ref;
switch (type) {
case TYPE_PART:
return (Part *)ref - me->_parts;
@@ -3155,8 +3156,9 @@
}
}
-void *IMuseInternal::loadReference(IMuseInternal *me, byte type, int ref)
+void *IMuseInternal::loadReference(void *me_ref, byte type, int ref)
{
+ IMuseInternal *me = (IMuseInternal *)me_ref;
switch (type) {
case TYPE_PART:
return &me->_parts[ref];
@@ -3170,88 +3172,88 @@
int IMuseInternal::save_or_load(Serializer *ser, Scumm *scumm)
{
const SaveLoadEntry mainEntries[] = {
- MKLINE(IMuseInternal, _queue_end, sleUint8),
- MKLINE(IMuseInternal, _queue_pos, sleUint8),
- MKLINE(IMuseInternal, _queue_sound, sleUint16),
- MKLINE(IMuseInternal, _queue_adding, sleByte),
- MKLINE(IMuseInternal, _queue_marker, sleByte),
- MKLINE(IMuseInternal, _queue_cleared, sleByte),
- MKLINE(IMuseInternal, _master_volume, sleByte),
- MKLINE(IMuseInternal, _trigger_count, sleUint16),
- MKARRAY(IMuseInternal, _channel_volume[0], sleUint16, 8),
- MKARRAY(IMuseInternal, _volchan_table[0], sleUint16, 8),
+ MKLINE(IMuseInternal, _queue_end, sleUint8, VER_V8),
+ MKLINE(IMuseInternal, _queue_pos, sleUint8, VER_V8),
+ MKLINE(IMuseInternal, _queue_sound, sleUint16, VER_V8),
+ MKLINE(IMuseInternal, _queue_adding, sleByte, VER_V8),
+ MKLINE(IMuseInternal, _queue_marker, sleByte, VER_V8),
+ MKLINE(IMuseInternal, _queue_cleared, sleByte, VER_V8),
+ MKLINE(IMuseInternal, _master_volume, sleByte, VER_V8),
+ MKLINE(IMuseInternal, _trigger_count, sleUint16, VER_V8),
+ MKARRAY(IMuseInternal, _channel_volume[0], sleUint16, 8, VER_V8),
+ MKARRAY(IMuseInternal, _volchan_table[0], sleUint16, 8, VER_V8),
MKEND()
};
const SaveLoadEntry playerEntries[] = {
- MKREF(Player, _parts, TYPE_PART),
- MKLINE(Player, _active, sleByte),
- MKLINE(Player, _id, sleUint16),
- MKLINE(Player, _priority, sleByte),
- MKLINE(Player, _volume, sleByte),
- MKLINE(Player, _pan, sleInt8),
- MKLINE(Player, _transpose, sleByte),
- MKLINE(Player, _detune, sleInt8),
- MKLINE(Player, _vol_chan, sleUint16),
- MKLINE(Player, _vol_eff, sleByte),
- MKLINE(Player, _speed, sleByte),
- MKLINE(Player, _song_index, sleUint16),
- MKLINE(Player, _track_index, sleUint16),
- MKLINE(Player, _timer_counter, sleUint16),
- MKLINE(Player, _loop_to_beat, sleUint16),
- MKLINE(Player, _loop_from_beat, sleUint16),
- MKLINE(Player, _loop_counter, sleUint16),
- MKLINE(Player, _loop_to_tick, sleUint16),
- MKLINE(Player, _loop_from_tick, sleUint16),
- MKLINE(Player, _tempo, sleUint32),
- MKLINE(Player, _cur_pos, sleUint32),
- MKLINE(Player, _next_pos, sleUint32),
- MKLINE(Player, _song_offset, sleUint32),
- MKLINE(Player, _tick_index, sleUint16),
- MKLINE(Player, _beat_index, sleUint16),
- MKLINE(Player, _ticks_per_beat, sleUint16),
- MKLINE(Player, _hook._jump, sleByte),
- MKLINE(Player, _hook._transpose, sleByte),
- MKARRAY(Player, _hook._part_onoff[0], sleByte, 16),
- MKARRAY(Player, _hook._part_volume[0], sleByte, 16),
- MKARRAY(Player, _hook._part_program[0], sleByte, 16),
- MKARRAY(Player, _hook._part_transpose[0], sleByte, 16),
+ MKREF(Player, _parts, TYPE_PART, VER_V8),
+ MKLINE(Player, _active, sleByte, VER_V8),
+ MKLINE(Player, _id, sleUint16, VER_V8),
+ MKLINE(Player, _priority, sleByte, VER_V8),
+ MKLINE(Player, _volume, sleByte, VER_V8),
+ MKLINE(Player, _pan, sleInt8, VER_V8),
+ MKLINE(Player, _transpose, sleByte, VER_V8),
+ MKLINE(Player, _detune, sleInt8, VER_V8),
+ MKLINE(Player, _vol_chan, sleUint16, VER_V8),
+ MKLINE(Player, _vol_eff, sleByte, VER_V8),
+ MKLINE(Player, _speed, sleByte, VER_V8),
+ MKLINE(Player, _song_index, sleUint16, VER_V8),
+ MKLINE(Player, _track_index, sleUint16, VER_V8),
+ MKLINE(Player, _timer_counter, sleUint16, VER_V8),
+ MKLINE(Player, _loop_to_beat, sleUint16, VER_V8),
+ MKLINE(Player, _loop_from_beat, sleUint16, VER_V8),
+ MKLINE(Player, _loop_counter, sleUint16, VER_V8),
+ MKLINE(Player, _loop_to_tick, sleUint16, VER_V8),
+ MKLINE(Player, _loop_from_tick, sleUint16, VER_V8),
+ MKLINE(Player, _tempo, sleUint32, VER_V8),
+ MKLINE(Player, _cur_pos, sleUint32, VER_V8),
+ MKLINE(Player, _next_pos, sleUint32, VER_V8),
+ MKLINE(Player, _song_offset, sleUint32, VER_V8),
+ MKLINE(Player, _tick_index, sleUint16, VER_V8),
+ MKLINE(Player, _beat_index, sleUint16, VER_V8),
+ MKLINE(Player, _ticks_per_beat, sleUint16, VER_V8),
+ MKLINE(Player, _hook._jump, sleByte, VER_V8),
+ MKLINE(Player, _hook._transpose, sleByte, VER_V8),
+ MKARRAY(Player, _hook._part_onoff[0], sleByte, 16, VER_V8),
+ MKARRAY(Player, _hook._part_volume[0], sleByte, 16, VER_V8),
+ MKARRAY(Player, _hook._part_program[0], sleByte, 16, VER_V8),
+ MKARRAY(Player, _hook._part_transpose[0], sleByte, 16, VER_V8),
MKEND()
};
const SaveLoadEntry volumeFaderEntries[] = {
- MKREF(VolumeFader, player, TYPE_PLAYER),
- MKLINE(VolumeFader, active, sleUint8),
- MKLINE(VolumeFader, curvol, sleUint8),
- MKLINE(VolumeFader, speed_lo_max, sleUint16),
- MKLINE(VolumeFader, num_steps, sleUint16),
- MKLINE(VolumeFader, speed_hi, sleInt8),
- MKLINE(VolumeFader, direction, sleInt8),
- MKLINE(VolumeFader, speed_lo, sleInt8),
- MKLINE(VolumeFader, speed_lo_counter, sleUint16),
+ MKREF(VolumeFader, player, TYPE_PLAYER, VER_V8),
+ MKLINE(VolumeFader, active, sleUint8, VER_V8),
+ MKLINE(VolumeFader, curvol, sleUint8, VER_V8),
+ MKLINE(VolumeFader, speed_lo_max, sleUint16, VER_V8),
+ MKLINE(VolumeFader, num_steps, sleUint16, VER_V8),
+ MKLINE(VolumeFader, speed_hi, sleInt8, VER_V8),
+ MKLINE(VolumeFader, direction, sleInt8, VER_V8),
+ MKLINE(VolumeFader, speed_lo, sleInt8, VER_V8),
+ MKLINE(VolumeFader, speed_lo_counter, sleUint16, VER_V8),
MKEND()
};
const SaveLoadEntry partEntries[] = {
- MKREF(Part, _next, TYPE_PART),
- MKREF(Part, _prev, TYPE_PART),
- MKREF(Part, _player, TYPE_PLAYER),
- MKLINE(Part, _pitchbend, sleInt16),
- MKLINE(Part, _pitchbend_factor, sleUint8),
- MKLINE(Part, _transpose, sleInt8),
- MKLINE(Part, _vol, sleUint8),
- MKLINE(Part, _detune, sleInt8),
- MKLINE(Part, _pan, sleInt8),
- MKLINE(Part, _on, sleUint8),
- MKLINE(Part, _modwheel, sleUint8),
- MKLINE(Part, _pedal, sleUint8),
- MKLINE(Part, _program, sleUint8),
- MKLINE(Part, _pri, sleUint8),
- MKLINE(Part, _chan, sleUint8),
- MKLINE(Part, _effect_level, sleUint8),
- MKLINE(Part, _chorus, sleUint8),
- MKLINE(Part, _percussion, sleUint8),
- MKLINE(Part, _bank, sleUint8),
+ MKREF(Part, _next, TYPE_PART, VER_V8),
+ MKREF(Part, _prev, TYPE_PART, VER_V8),
+ MKREF(Part, _player, TYPE_PLAYER, VER_V8),
+ MKLINE(Part, _pitchbend, sleInt16, VER_V8),
+ MKLINE(Part, _pitchbend_factor, sleUint8, VER_V8),
+ MKLINE(Part, _transpose, sleInt8, VER_V8),
+ MKLINE(Part, _vol, sleUint8, VER_V8),
+ MKLINE(Part, _detune, sleInt8, VER_V8),
+ MKLINE(Part, _pan, sleInt8, VER_V8),
+ MKLINE(Part, _on, sleUint8, VER_V8),
+ MKLINE(Part, _modwheel, sleUint8, VER_V8),
+ MKLINE(Part, _pedal, sleUint8, VER_V8),
+ MKLINE(Part, _program, sleUint8, VER_V8),
+ MKLINE(Part, _pri, sleUint8, VER_V8),
+ MKLINE(Part, _chan, sleUint8, VER_V8),
+ MKLINE(Part, _effect_level, sleUint8, VER_V8),
+ MKLINE(Part, _chorus, sleUint8, VER_V8),
+ MKLINE(Part, _percussion, sleUint8, VER_V8),
+ MKLINE(Part, _bank, sleUint8, VER_V8),
MKEND()
};
@@ -3261,7 +3263,8 @@
#endif
ser->_ref_me = this;
- ser->_saveload_ref = ser->isSaving()? ((void *)&saveReference) : ((void *)&loadReference);
+ ser->_save_ref = saveReference;
+ ser->_load_ref = loadReference;
ser->saveLoadEntries(this, mainEntries);
ser->saveLoadArrayOf(_players, ARRAYSIZE(_players), sizeof(_players[0]), playerEntries);
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- saveload.cpp 7 Dec 2002 20:28:40 -0000 1.27
+++ saveload.cpp 8 Dec 2002 16:14:28 -0000 1.28
@@ -38,23 +38,12 @@
char name[32];
};
-// Support for "old" savegames (made with 2501 CVS build)
-// Can be useful for other ports too :)
-
-#define VER_V9 9
-#define VER_V8 8
-#define VER_V7 7
-
-#define CURRENT_VER VER_V9
[...1038 lines suppressed...]
+ // load reference...
+ int num = loadWord();
+ // ...but only use it if it's still there in CURRENT_VER
+ if (sle->maxVersion == CURRENT_VER)
+ *((void **)at) = num ? (*_load_ref) (_ref_me, type, num - 1) : NULL;
} else {
- replen = 1;
+ // load entry
+ int replen = 1;
+
if (type & 128) {
sle++;
replen = sle->offs;
type &= ~128;
}
- saveLoadArrayOf(at, replen, size, type);
+ loadArrayOf(at, replen, size, type);
}
sle++;
}
Index: saveload.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- saveload.h 22 Sep 2002 03:57:41 -0000 1.4
+++ saveload.h 8 Dec 2002 16:14:29 -0000 1.5
@@ -22,6 +22,17 @@
#ifndef SAVELOAD_H
#define SAVELOAD_H
+// Support for "old" savegames (made with 2501 CVS build)
+// Can be useful for other ports too :)
+
+#define VER_V10 10
+#define VER_V9 9
+#define VER_V8 8
+#define VER_V7 7
+
+#define CURRENT_VER VER_V10
+
+
// To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types,
// we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC
// versions hae a heuristic built in to detect "offset-of" patterns - which is exactly
@@ -32,11 +43,29 @@
#define OFFS(type,item) (((int)(&((type*)42)->type::item))-42)
#define SIZE(type,item) sizeof(((type*)42)->type::item)
-#define MKLINE(type,item,saveas) {OFFS(type,item),saveas,SIZE(type,item)}
-#define MKARRAY(type,item,saveas,num) {OFFS(type,item),128|saveas,SIZE(type,item)}, {num,0,0}
-#define MKEND() {0xFFFF,0xFF,0xFF}
-#define MKREF(type,item,refid) {OFFS(type,item),refid,0xFF}
+// Any item that is still in use automatically gets a maxVersion equal to CURRENT_VER
+#define MKLINE(type,item,saveas,minVer) {OFFS(type,item),saveas,SIZE(type,item),minVer,CURRENT_VER}
+#define MKARRAY(type,item,saveas,num,minVer) {OFFS(type,item),128|saveas,SIZE(type,item),minVer,CURRENT_VER}, {num,0,0,0,0}
+
+// Use this if you have an entry that used to be smaller:
+#define MKLINE_OLD(type,item,saveas,minVer,maxVer) {OFFS(type,item),saveas,SIZE(type,item),minVer,maxVer}
+#define MKARRAY_OLD(type,item,saveas,num,minVer,maxVer) {OFFS(type,item),128|saveas,SIZE(type,item),minVer,maxVer}, {num,0,0,0,0}
+
+// An obsolete item/array, to be ignored upon load. We retain the type/item params to make it easier to debug.
+// Obsolete items have size == 0.
+#define MK_OBSOLETE(type,item,saveas,minVer,maxVer) {0,saveas,0,minVer,maxVer}
+#define MK_OBSOLETE_ARRAY(type,item,saveas,num,minVer,maxVer) {0,128|saveas,0,minVer,maxVer}, {num,0,0,0,0}
+
+// End marker
+#define MKEND() {0xFFFF,0xFF,0xFF,0,0}
+
+// A reference
+#define MKREF(type,item,refid,minVer) {OFFS(type,item),refid,0xFF,minVer,CURRENT_VER}
+
+// An obsolete reference.
+#define MK_OBSOLETE_REF(type,item,refid,minVer,maxVer) {0,sleUint16,0,minVer,maxVer}
+
enum {
sleByte = 1,
@@ -52,6 +81,8 @@
uint32 offs;
uint8 type;
uint8 size;
+ uint8 minVersion;
+ uint8 maxVersion;
};
struct SerializerStream {
@@ -83,24 +114,25 @@
typedef int SerializerSaveReference(void *me, byte type, void *ref);
typedef void *SerializerLoadReference(void *me, byte type, int ref);
-struct Serializer {
- SerializerStream _saveLoadStream;
+class Serializer {
+public:
+ Serializer(SerializerStream stream, bool saveOrLoad, uint32 savegameVersion)
+ : _save_ref(0), _load_ref(0), _ref_me(0),
+ _saveLoadStream(stream), _saveOrLoad(saveOrLoad),
+ _savegameVersion(savegameVersion)
+ { }
- union {
- SerializerSaveReference *_save_ref;
- SerializerLoadReference *_load_ref;
- void *_saveload_ref;
- };
+ SerializerSaveReference *_save_ref;
+ SerializerLoadReference *_load_ref;
void *_ref_me;
- bool _saveOrLoad;
-
- void saveBytes(void *b, int len);
- void loadBytes(void *b, int len);
-
void saveLoadArrayOf(void *b, int len, int datasize, byte filetype);
- void saveLoadEntries(void *d, const SaveLoadEntry *sle);
void saveLoadArrayOf(void *b, int num, int datasize, const SaveLoadEntry *sle);
+ void saveLoadEntries(void *d, const SaveLoadEntry *sle);
+
+ bool isSaving() { return _saveOrLoad; }
+
+ bool checkEOFLoadStream();
void saveUint32(uint32 d);
void saveWord(uint16 d);
@@ -110,10 +142,19 @@
uint16 loadWord();
uint32 loadUint32();
- bool isSaving() { return _saveOrLoad; }
+ void saveBytes(void *b, int len);
+ void loadBytes(void *b, int len);
+
+protected:
+ SerializerStream _saveLoadStream;
+ bool _saveOrLoad;
+ uint32 _savegameVersion;
- bool checkEOFLoadStream();
+ void saveArrayOf(void *b, int len, int datasize, byte filetype);
+ void loadArrayOf(void *b, int len, int datasize, byte filetype);
+ void saveEntries(void *d, const SaveLoadEntry *sle);
+ void loadEntries(void *d, const SaveLoadEntry *sle);
};
#endif
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- scumm.h 4 Dec 2002 22:34:37 -0000 1.72
+++ scumm.h 8 Dec 2002 16:14:29 -0000 1.73
@@ -359,7 +359,6 @@
void convertKeysToClicks();
/* Random number generation */
- uint32 _randSeed1, _randSeed2; // FIXME: can be removed when new savegame system is implemented
RandomSource _rnd;
/* Core variable definitions */
@@ -427,6 +426,8 @@
bool _saveLoadCompatible;
char _saveLoadName[32];
+ uint32 _savegameVersion;
+
bool saveState(int slot, bool compat);
bool loadState(int slot, bool compat);
void saveOrLoad(Serializer *s);
@@ -692,7 +693,7 @@
ColorCycle _colorCycle[16]; // Palette cycles
uint32 _ENCD_offs, _EXCD_offs;
- uint32 _CLUT_offs, _EPAL_offs;
+ uint32 _CLUT_offs;
uint32 _IM00_offs, _PALS_offs;
//ender: fullscreen
@@ -856,7 +857,6 @@
bool _silentDigitalImuse;
int _saveSound;
int current_cd_sound;
- int _cd_loops, _cd_frame, _cd_track, _cd_end; // FIXME - these are not used anymore
/* Walkbox / Navigation class */
int _maxBoxVertexHeap, _boxPathVertexHeapIndex, _boxMatrixItem;
More information about the Scummvm-git-logs
mailing list