mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Delay skin setting on save load until player class is known.
- Fixed: Loading players from savegames set the skin before their current class was retrieved, so they could not validate their skins with the correct class.
This commit is contained in:
parent
7052d4e14e
commit
db4763b14a
3 changed files with 26 additions and 24 deletions
|
@ -941,14 +941,21 @@ void WriteUserInfo(FArchive &arc, userinfo_t &info)
|
||||||
arc << name;
|
arc << name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadUserInfo(FArchive &arc, userinfo_t &info)
|
void ReadUserInfo(FArchive &arc, userinfo_t &info, FString &skin)
|
||||||
{
|
{
|
||||||
FName name;
|
FName name;
|
||||||
FBaseCVar **cvar;
|
FBaseCVar **cvar;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
UCVarValue val;
|
UCVarValue val;
|
||||||
|
|
||||||
|
if (SaveVersion < 4253)
|
||||||
|
{
|
||||||
|
ReadCompatibleUserInfo(arc, info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
info.Reset();
|
info.Reset();
|
||||||
|
skin = NULL;
|
||||||
for (arc << name; name != NAME_None; arc << name)
|
for (arc << name; name != NAME_None; arc << name)
|
||||||
{
|
{
|
||||||
cvar = info.CheckKey(name);
|
cvar = info.CheckKey(name);
|
||||||
|
@ -958,7 +965,7 @@ void ReadUserInfo(FArchive &arc, userinfo_t &info)
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case NAME_Team: info.TeamChanged(atoi(str)); break;
|
case NAME_Team: info.TeamChanged(atoi(str)); break;
|
||||||
case NAME_Skin: info.SkinChanged(str, 0); break;
|
case NAME_Skin: skin = str; break; // Caller must call SkinChanged() once current calss is known
|
||||||
case NAME_PlayerClass: info.PlayerClassChanged(str); break;
|
case NAME_PlayerClass: info.PlayerClassChanged(str); break;
|
||||||
default:
|
default:
|
||||||
val.String = str;
|
val.String = str;
|
||||||
|
@ -973,23 +980,6 @@ void ReadUserInfo(FArchive &arc, userinfo_t &info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FArchive &operator<< (FArchive &arc, userinfo_t &info)
|
|
||||||
{
|
|
||||||
if (SaveVersion < 4253)
|
|
||||||
{
|
|
||||||
ReadCompatibleUserInfo(arc, info);
|
|
||||||
}
|
|
||||||
else if (arc.IsStoring())
|
|
||||||
{
|
|
||||||
WriteUserInfo(arc, info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReadUserInfo(arc, info);
|
|
||||||
}
|
|
||||||
return arc;
|
|
||||||
}
|
|
||||||
|
|
||||||
CCMD (playerinfo)
|
CCMD (playerinfo)
|
||||||
{
|
{
|
||||||
if (argv.argc() < 2)
|
if (argv.argc() < 2)
|
||||||
|
|
|
@ -342,8 +342,8 @@ struct userinfo_t : TMap<FName,FBaseCVar *>
|
||||||
int ColorSetChanged(int setnum);
|
int ColorSetChanged(int setnum);
|
||||||
};
|
};
|
||||||
|
|
||||||
FArchive &operator<< (FArchive &arc, userinfo_t &info);
|
void ReadUserInfo(FArchive &arc, userinfo_t &info, FString &skin);
|
||||||
|
void WriteUserInfo(FArchive &arc, userinfo_t &info);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Extended player object info: player_t
|
// Extended player object info: player_t
|
||||||
|
|
|
@ -2742,14 +2742,22 @@ void P_UnPredictPlayer ()
|
||||||
void player_t::Serialize (FArchive &arc)
|
void player_t::Serialize (FArchive &arc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
FString skinname;
|
||||||
|
|
||||||
arc << cls
|
arc << cls
|
||||||
<< mo
|
<< mo
|
||||||
<< camera
|
<< camera
|
||||||
<< playerstate
|
<< playerstate
|
||||||
<< cmd
|
<< cmd;
|
||||||
<< userinfo
|
if (arc.IsLoading())
|
||||||
<< DesiredFOV << FOV
|
{
|
||||||
|
ReadUserInfo(arc, userinfo, skinname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteUserInfo(arc, userinfo);
|
||||||
|
}
|
||||||
|
arc << DesiredFOV << FOV
|
||||||
<< viewz
|
<< viewz
|
||||||
<< viewheight
|
<< viewheight
|
||||||
<< deltaviewheight
|
<< deltaviewheight
|
||||||
|
@ -2900,6 +2908,10 @@ void player_t::Serialize (FArchive &arc)
|
||||||
oldbuttons = ~0;
|
oldbuttons = ~0;
|
||||||
original_oldbuttons = ~0;
|
original_oldbuttons = ~0;
|
||||||
}
|
}
|
||||||
|
if (skinname.IsNotEmpty())
|
||||||
|
{
|
||||||
|
userinfo.SkinChanged(skinname, CurrentPlayerClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue