TSAGE: Reworked the saving code to fix crashes
Note that this undoes the recent compilation fix for GCC, since it didn't work. For now, used an explicit void ** conversion as previously suggested.
This commit is contained in:
parent
d18f8e8564
commit
5dcfd1e32c
5 changed files with 45 additions and 7 deletions
|
@ -151,13 +151,13 @@ Common::Error Saver::save(int slot, const Common::String &saveName) {
|
|||
}
|
||||
|
||||
Common::Error Saver::restore(int slot) {
|
||||
assert(!getMacroSaveFlag());
|
||||
assert(!getMacroRestoreFlag());
|
||||
|
||||
// Signal any objects registered for notification
|
||||
_loadNotifiers.notify(false);
|
||||
|
||||
// Set fields
|
||||
_macroSaveFlag = true;
|
||||
_macroRestoreFlag = true;
|
||||
_saveSlot = slot;
|
||||
_unresolvedPtrs.clear();
|
||||
|
||||
|
@ -335,7 +335,7 @@ bool Saver::savegamesExist() const {
|
|||
*/
|
||||
int Saver::blockIndexOf(SavedObject *p) {
|
||||
int objIndex = 1;
|
||||
SynchronisedList<SavedObject *>::iterator iObj;
|
||||
Common::List<SavedObject *>::iterator iObj;
|
||||
|
||||
for (iObj = _objList.begin(); iObj != _objList.end(); ++iObj, ++objIndex) {
|
||||
SavedObject *iObjP = *iObj;
|
||||
|
@ -346,6 +346,30 @@ int Saver::blockIndexOf(SavedObject *p) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of objects in the object list registry
|
||||
*/
|
||||
int Saver::getObjectCount() const {
|
||||
int count = 0;
|
||||
Common::List<SavedObject *>::const_iterator i;
|
||||
|
||||
for (i = _objList.begin(); i != _objList.end(); ++i, ++count)
|
||||
;
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* List any currently active objects
|
||||
*/
|
||||
void Saver::listObjects() {
|
||||
Common::List<SavedObject *>::iterator i;
|
||||
int count = 1;
|
||||
|
||||
for (i = _objList.begin(); i != _objList.end(); ++i, ++count)
|
||||
debug("%d - %s", count, (*i)->getClassName().c_str());
|
||||
debug("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pointer associated with the specified object index
|
||||
*/
|
||||
|
@ -358,12 +382,14 @@ void Saver::resolveLoadPointers() {
|
|||
int objIndex = 1;
|
||||
for (SynchronisedList<SavedObject *>::iterator iObj = _objList.begin(); iObj != _objList.end(); ++iObj, ++objIndex) {
|
||||
Common::List<SavedObjectRef>::iterator iPtr;
|
||||
SavedObject *pObj = *iObj;
|
||||
|
||||
for (iPtr = _unresolvedPtrs.begin(); iPtr != _unresolvedPtrs.end(); ) {
|
||||
SavedObjectRef &r = *iPtr;
|
||||
if (r._objIndex == objIndex) {
|
||||
// Found an unresolved pointer to this object
|
||||
*r._savedObject = *iObj;
|
||||
SavedObject **objPP = r._savedObject;
|
||||
*objPP = pObj;
|
||||
iPtr = _unresolvedPtrs.erase(iPtr);
|
||||
} else {
|
||||
++iPtr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue