Skip to content

Commit

Permalink
libcommon: Bumped save state version to 12
Browse files Browse the repository at this point in the history
The indexing scheme for map Sides has changed therefore we need a
new save state version. Side indices in older save states will be
translated as necessary.
  • Loading branch information
danij-deng committed Apr 24, 2013
1 parent e190710 commit 3c9ef3d
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 117 deletions.
25 changes: 14 additions & 11 deletions doomsday/plugins/common/include/dmu_archiveindex.h
Expand Up @@ -32,6 +32,7 @@ namespace dmu_lib {
*
* @note Population of the index is deferred until it is first accessed.
*/
template <int ElementType>
class ArchiveIndex
{
public:
Expand All @@ -40,16 +41,13 @@ class ArchiveIndex
*
* @param elementType DMU element type of the objects to be indexed.
*/
ArchiveIndex(int elementType)
: _elementType(elementType),
_indexBase(-1),
_lut(0)
ArchiveIndex() : _indexBase(-1), _lut(0)
{}

/**
* Returns the DMU element type which "this" indexes.
*/
int type() const { return _elementType; }
int type() const { return ElementType; }

/**
* Returns a pointer to the DMU object associated with the specified @a index.
Expand Down Expand Up @@ -92,11 +90,11 @@ class ArchiveIndex
minIdx = DDMAXINT;
maxIdx = DDMININT;

int numElements = P_Count(_elementType);
int numElements = P_Count(ElementType);
for(int i = 0; i < numElements; ++i)
{
MapElementPtr element = P_ToPtr(_elementType, i);
DENG_ASSERT(DMU_GetType(element) == _elementType);
MapElementPtr element = P_ToPtr(ElementType, i);
DENG_ASSERT(DMU_GetType(element) == ElementType);
int index = P_GetIntp(element, DMU_ARCHIVE_INDEX);

// Not indexed?
Expand Down Expand Up @@ -143,21 +141,26 @@ class ArchiveIndex
_lut.reset(new ElementLut(lutSize, 0));

// Populate the LUT.
int numElements = P_Count(_elementType);
int numElements = P_Count(ElementType);
for(int i = 0; i < numElements; ++i)
{
linkInLut(P_ToPtr(_elementType, i));
linkInLut(P_ToPtr(ElementType, i));
}
}

private:
typedef std::vector<MapElementPtr> ElementLut;

int _elementType;
int _indexBase;
std::auto_ptr<ElementLut> _lut;
};

///@{
typedef ArchiveIndex<DMU_LINE> LineArchive; ///< ArchiveIndex of DMU_LINE
typedef ArchiveIndex<DMU_SIDE> SideArchive; ///< ArchiveIndex of DMU_SIDE
typedef ArchiveIndex<DMU_SECTOR> SectorArchive; ///< ArchiveIndex of DMU_SECTOR
///@}

} // namespace dmu_lib

#endif // LIBCOMMON_DMU_ARCHIVEINDEX_H
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/p_savedef.h
Expand Up @@ -21,7 +21,7 @@
#ifndef LIBCOMMON_SAVEGAME_DEFS_H
#define LIBCOMMON_SAVEGAME_DEFS_H

#define MY_SAVE_VERSION 11
#define MY_SAVE_VERSION 12

#if __JDOOM__
# define MY_SAVE_MAGIC 0x1DEAD666
Expand Down

0 comments on commit 3c9ef3d

Please sign in to comment.