From e2c8a6f8594d58305a17918dd6bf07be9afc3b0b Mon Sep 17 00:00:00 2001 From: danij Date: Fri, 21 Mar 2014 03:38:18 +0000 Subject: [PATCH] libcommon|MapStateWriter: Optionally exclude players from the map state thing archive --- doomsday/plugins/common/include/mapstatewriter.h | 4 +++- doomsday/plugins/common/src/g_game.cpp | 9 ++------- doomsday/plugins/common/src/mapstatewriter.cpp | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/doomsday/plugins/common/include/mapstatewriter.h b/doomsday/plugins/common/include/mapstatewriter.h index ae88473707..d8e5fb8114 100644 --- a/doomsday/plugins/common/include/mapstatewriter.h +++ b/doomsday/plugins/common/include/mapstatewriter.h @@ -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. diff --git a/doomsday/plugins/common/src/g_game.cpp b/doomsday/plugins/common/src/g_game.cpp index f32aae04e1..8620c2a744 100644 --- a/doomsday/plugins/common/src/g_game.cpp +++ b/doomsday/plugins/common/src/g_game.cpp @@ -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(); } } diff --git a/doomsday/plugins/common/src/mapstatewriter.cpp b/doomsday/plugins/common/src/mapstatewriter.cpp index 84828377c6..2a69173276 100644 --- a/doomsday/plugins/common/src/mapstatewriter.cpp +++ b/doomsday/plugins/common/src/mapstatewriter.cpp @@ -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; @@ -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