- handle USERSAVE.

This commit is contained in:
Christoph Oelckers 2021-12-25 21:08:03 +01:00
parent afe93f89af
commit a72732a7b1
3 changed files with 27 additions and 25 deletions

View file

@ -527,7 +527,7 @@ void TerminateLevel(void)
SWStatIterator it(stat);
if (auto actor = it.Next())
{
if (actor->hasU()) puser[pnum].CopyFromUser(actor->u());
if (actor->hasU()) puser[pnum].CopyFromUser(actor);
}
}

View file

@ -1100,27 +1100,6 @@ struct USER
using USERp = USER*;
struct USERSAVE
{
int16_t Health;
int8_t WeaponNum;
int8_t LastWeaponNum;
void CopyFromUser(USER* u)
{
Health = u->Health;
WeaponNum = u->WeaponNum;
LastWeaponNum = u->LastWeaponNum;
}
void CopyToUser(USER* u)
{
u->Health = Health;
u->WeaponNum = WeaponNum;
u->LastWeaponNum = LastWeaponNum;
}
};
enum
{
@ -1819,8 +1798,6 @@ extern short connecthead, connectpoint2[MAXPLAYERS];
*/
extern int *lastpacket2clock;
// save player info when moving to a new level (shortened to only cover the fields that actually are copied back.(
extern USERSAVE puser[MAX_SW_PLAYERS_REG];
///////////////////////////
//
@ -2222,6 +2199,31 @@ struct ANIMstruct
extern ANIM Anim[MAXANIM];
extern short AnimCnt;
struct USERSAVE
{
int16_t Health;
int8_t WeaponNum;
int8_t LastWeaponNum;
void CopyFromUser(DSWActor* u)
{
Health = u->user.Health;
WeaponNum = u->user.WeaponNum;
LastWeaponNum = u->user.LastWeaponNum;
}
void CopyToUser(DSWActor* u)
{
u->user.Health = Health;
u->user.WeaponNum = WeaponNum;
u->user.LastWeaponNum = LastWeaponNum;
}
};
// save player info when moving to a new level (shortened to only cover the fields that actually are copied back.)
extern USERSAVE puser[MAX_SW_PLAYERS_REG];
END_SW_NS

View file

@ -2400,7 +2400,7 @@ void InitPlayerSprite(PLAYERp pp)
else
{
// restore stuff from last level
puser[pnum].CopyToUser(u);
puser[pnum].CopyToUser(actor);
PlayerLevelReset(pp);
}