Skip to content

Commit

Permalink
libcommon|MapStateWriter: Optionally exclude players from the map sta…
Browse files Browse the repository at this point in the history
…te thing archive
  • Loading branch information
danij-deng committed Mar 21, 2014
1 parent b445f71 commit e2c8a6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 3 additions & 1 deletion doomsday/plugins/common/include/mapstatewriter.h
Expand Up @@ -37,8 +37,10 @@ class MapStateWriter

/**
* Serialize the map state using the specified @a reader.
*
* @param excludePlayers @c true= Do not include players in the ThingArchive.
*/
void write(Writer *writer);
void write(Writer *writer, bool excludePlayers = false);

/**
* Returns the writer to use when serializing the map state.
Expand Down
9 changes: 2 additions & 7 deletions doomsday/plugins/common/src/g_game.cpp
Expand Up @@ -3008,14 +3008,9 @@ void G_DoLeaveMap()
}

Writer *writer = SV_NewWriter();

// Set the mobj archive numbers
ThingArchive thingArchive;
thingArchive.initForSave(true/*exclude players*/);

MapStateWriter(thingArchive).write(writer);

MapStateWriter().write(writer, true/*exclude players*/);
Writer_Delete(writer);

SV_CloseFile();
}
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/mapstatewriter.cpp
Expand Up @@ -299,7 +299,7 @@ DENG2_PIMPL(MapStateWriter)
MapStateWriter::MapStateWriter() : d(new Instance(this))
{}

void MapStateWriter::write(Writer *writer)
void MapStateWriter::write(Writer *writer, bool excludePlayers)
{
DENG_ASSERT(writer != 0);
d->writer = writer;
Expand All @@ -312,7 +312,7 @@ void MapStateWriter::write(Writer *writer)

// Set the mobj archive numbers.
d->thingArchive = new ThingArchive;
d->thingArchive->initForSave(false/*do not exclude players*/);
d->thingArchive->initForSave(excludePlayers);
#if !__JHEXEN__
Writer_WriteInt32(d->writer, d->thingArchive->size());
#endif
Expand Down

0 comments on commit e2c8a6f

Please sign in to comment.