- let's save the terrain properties as names so that they survive a change in the definition files.

This commit is contained in:
Christoph Oelckers 2016-01-09 12:28:42 +01:00
parent 7f454358b9
commit 23cfd29dbb
4 changed files with 30 additions and 2 deletions

View file

@ -193,7 +193,7 @@ void AActor::Serialize (FArchive &arc)
<< Damage; << Damage;
if (SaveVersion >= 4530) if (SaveVersion >= 4530)
{ {
arc << floorterrain; P_SerializeTerrain(arc, floorterrain);
} }
if (SaveVersion >= 3227) if (SaveVersion >= 3227)
{ {

View file

@ -52,6 +52,7 @@
#include "farchive.h" #include "farchive.h"
#include "p_lnspec.h" #include "p_lnspec.h"
#include "p_acs.h" #include "p_acs.h"
#include "p_terrain.h"
static void CopyPlayer (player_t *dst, player_t *src, const char *name); static void CopyPlayer (player_t *dst, player_t *src, const char *name);
static void ReadOnePlayer (FArchive &arc, bool skipload); static void ReadOnePlayer (FArchive &arc, bool skipload);
@ -371,7 +372,8 @@ void P_SerializeWorld (FArchive &arc)
<< sec->gravity; << sec->gravity;
if (SaveVersion >= 4530) if (SaveVersion >= 4530)
{ {
arc << sec->terrainnum[0] << sec->terrainnum[1]; P_SerializeTerrain(arc, sec->terrainnum[0]);
P_SerializeTerrain(arc, sec->terrainnum[1]);
} }
if (SaveVersion >= 4529) if (SaveVersion >= 4529)
{ {

View file

@ -46,6 +46,7 @@
#include "s_sound.h" #include "s_sound.h"
#include "p_local.h" #include "p_local.h"
#include "templates.h" #include "templates.h"
#include "farchive.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -704,3 +705,26 @@ int P_FindTerrain (FName name)
} }
return -1; return -1;
} }
void P_SerializeTerrain(FArchive &arc, int &terrainnum)
{
FName val;
if (arc.IsStoring())
{
if (terrainnum < 0 || terrainnum >= (int)Terrains.Size())
{
val = NAME_Null;
}
else
{
val = Terrains[terrainnum].Name;
}
arc << val;
}
else
{
arc << val;
terrainnum = P_FindTerrain(val);
}
}

View file

@ -122,6 +122,8 @@ struct FTerrainDef
extern TArray<FSplashDef> Splashes; extern TArray<FSplashDef> Splashes;
extern TArray<FTerrainDef> Terrains; extern TArray<FTerrainDef> Terrains;
class FArchive;
int P_FindTerrain(FName name); int P_FindTerrain(FName name);
void P_SerializeTerrain(FArchive &arc, int &terrainnum);
#endif //__P_TERRAIN_H__ #endif //__P_TERRAIN_H__