This commit is contained in:
Christoph Oelckers 2014-05-21 15:25:56 +02:00
commit 360e7d17f2
3 changed files with 64 additions and 50 deletions

View file

@ -1597,30 +1597,9 @@ void G_UnSnapshotLevel (bool hubLoad)
// //
//========================================================================== //==========================================================================
static void writeMapName (FArchive &arc, const char *name)
{
BYTE size;
if (name[7] != 0)
{
size = 8;
}
else
{
size = (BYTE)strlen (name);
}
arc << size;
arc.Write (name, size);
}
//==========================================================================
//
//
//==========================================================================
static void writeSnapShot (FArchive &arc, level_info_t *i) static void writeSnapShot (FArchive &arc, level_info_t *i)
{ {
arc << i->snapshotVer; arc << i->snapshotVer << i->MapName;
writeMapName (arc, i->MapName);
i->snapshot->Serialize (arc); i->snapshot->Serialize (arc);
} }
@ -1658,14 +1637,14 @@ void G_WriteSnapshots (FILE *file)
{ {
arc = new FPNGChunkArchive (file, VIST_ID); arc = new FPNGChunkArchive (file, VIST_ID);
} }
writeMapName (*arc, wadlevelinfos[i].MapName); (*arc) << wadlevelinfos[i].MapName;
} }
} }
if (arc != NULL) if (arc != NULL)
{ {
BYTE zero = 0; FString empty = "";
*arc << zero; (*arc) << empty;
delete arc; delete arc;
} }
@ -1706,6 +1685,7 @@ void G_ReadSnapshots (PNGHandle *png)
DWORD chunkLen; DWORD chunkLen;
BYTE namelen; BYTE namelen;
char mapname[256]; char mapname[256];
FString MapName;
level_info_t *i; level_info_t *i;
G_ClearSnapshots (); G_ClearSnapshots ();
@ -1717,10 +1697,15 @@ void G_ReadSnapshots (PNGHandle *png)
DWORD snapver; DWORD snapver;
arc << snapver; arc << snapver;
arc << namelen; if (SaveVersion < 4508)
arc.Read (mapname, namelen); {
mapname[namelen] = 0; arc << namelen;
i = FindLevelInfo (mapname); arc.Read(mapname, namelen);
mapname[namelen] = 0;
MapName = mapname;
}
else arc << MapName;
i = FindLevelInfo (MapName);
i->snapshotVer = snapver; i->snapshotVer = snapver;
i->snapshot = new FCompressedMemFile; i->snapshot = new FCompressedMemFile;
i->snapshot->Serialize (arc); i->snapshot->Serialize (arc);
@ -1746,14 +1731,25 @@ void G_ReadSnapshots (PNGHandle *png)
{ {
FPNGChunkArchive arc (png->File->GetFile(), VIST_ID, chunkLen); FPNGChunkArchive arc (png->File->GetFile(), VIST_ID, chunkLen);
arc << namelen; if (SaveVersion < 4508)
while (namelen != 0)
{ {
arc.Read (mapname, namelen);
mapname[namelen] = 0;
i = FindLevelInfo (mapname);
i->flags |= LEVEL_VISITED;
arc << namelen; arc << namelen;
while (namelen != 0)
{
arc.Read(mapname, namelen);
mapname[namelen] = 0;
i = FindLevelInfo(mapname);
i->flags |= LEVEL_VISITED;
arc << namelen;
}
}
else
{
while (arc << MapName, MapName.Len() > 0)
{
i = FindLevelInfo(MapName);
i->flags |= LEVEL_VISITED;
}
} }
} }
@ -1809,8 +1805,7 @@ CCMD(listsnapshots)
static void writeDefereds (FArchive &arc, level_info_t *i) static void writeDefereds (FArchive &arc, level_info_t *i)
{ {
writeMapName (arc, i->MapName); arc << i->MapName << i->defered;
arc << i->defered;
} }
//========================================================================== //==========================================================================
@ -1837,8 +1832,8 @@ void P_WriteACSDefereds (FILE *file)
if (arc != NULL) if (arc != NULL)
{ {
// Signal end of defereds // Signal end of defereds
BYTE zero = 0; FString empty = "";
*arc << zero; (*arc) << empty;
delete arc; delete arc;
} }
} }
@ -1852,6 +1847,7 @@ void P_ReadACSDefereds (PNGHandle *png)
{ {
BYTE namelen; BYTE namelen;
char mapname[256]; char mapname[256];
FString MapName;
size_t chunklen; size_t chunklen;
P_RemoveDefereds (); P_RemoveDefereds ();
@ -1860,18 +1856,33 @@ void P_ReadACSDefereds (PNGHandle *png)
{ {
FPNGChunkArchive arc (png->File->GetFile(), ACSD_ID, chunklen); FPNGChunkArchive arc (png->File->GetFile(), ACSD_ID, chunklen);
arc << namelen; if (SaveVersion < 4508)
while (namelen)
{ {
arc.Read (mapname, namelen);
mapname[namelen] = 0;
level_info_t *i = FindLevelInfo (mapname);
if (i == NULL)
{
I_Error ("Unknown map '%s' in savegame", mapname);
}
arc << i->defered;
arc << namelen; arc << namelen;
while (namelen != 0)
{
arc.Read(mapname, namelen);
mapname[namelen] = 0;
level_info_t *i = FindLevelInfo(mapname);
if (i == NULL)
{
I_Error("Unknown map '%s' in savegame", mapname);
}
arc << i->defered;
arc << namelen;
}
}
else
{
while (arc << MapName, MapName.Len() > 0)
{
level_info_t *i = FindLevelInfo(MapName);
if (i == NULL)
{
I_Error("Unknown map '%s' in savegame", MapName.GetChars());
}
arc << i->defered;
}
} }
} }
png->File->ResetFilePtr(); png->File->ResetFilePtr();

View file

@ -208,6 +208,9 @@ void P_BringUpWeapon (player_t *player)
player->psprites[ps_weapon].sy = player->cheats & CF_INSTANTWEAPSWITCH player->psprites[ps_weapon].sy = player->cheats & CF_INSTANTWEAPSWITCH
? WEAPONTOP : WEAPONBOTTOM; ? WEAPONTOP : WEAPONBOTTOM;
P_SetPsprite (player, ps_weapon, newstate); P_SetPsprite (player, ps_weapon, newstate);
// make sure that the previous weapon's flash state is terminated.
// When coming here from a weapon drop it may still be active.
P_SetPsprite(player, ps_flash, NULL);
} }

View file

@ -76,7 +76,7 @@ const char *GetVersionString();
// Use 4500 as the base git save version, since it's higher than the // Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got. // SVN revision ever got.
#define SAVEVER 4507 #define SAVEVER 4508
#define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY2(x) #x
#define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)