Skip to content

Commit 4c27b55

Browse files
jon-heardmadame-rachelle
authored andcommitted
SetSkin and GetSkinCount added to PlayerInfo class
1 parent 9b8c79d commit 4c27b55

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/playsim/p_user.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,23 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetFOV)
520520
return 0;
521521
}
522522

523+
DEFINE_ACTION_FUNCTION(_PlayerInfo, SetSkin)
524+
{
525+
PARAM_SELF_STRUCT_PROLOGUE(player_t);
526+
PARAM_INT(skinIndex);
527+
if (skinIndex >= 0 && skinIndex < Skins.size())
528+
{
529+
// commented code - cvar_set calls this automatically, along with saving the skin selection.
530+
//self->userinfo.SkinNumChanged(skinIndex);
531+
cvar_set("skin", Skins[skinIndex].Name.GetChars());
532+
ACTION_RETURN_INT(self->userinfo.GetSkin());
533+
}
534+
else
535+
{
536+
ACTION_RETURN_INT(-1);
537+
}
538+
}
539+
523540
//===========================================================================
524541
//
525542
// EnumColorsets
@@ -773,6 +790,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetSkin)
773790
ACTION_RETURN_INT(self->userinfo.GetSkin());
774791
}
775792

793+
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetSkinCount)
794+
{
795+
PARAM_SELF_STRUCT_PROLOGUE(player_t);
796+
ACTION_RETURN_INT(Skins.size());
797+
}
798+
776799
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetGender)
777800
{
778801
PARAM_SELF_STRUCT_PROLOGUE(player_t);

wadsrc/static/zscript/actors/player/player.zs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,7 @@ struct PlayerInfo native play // self is what internally is known as player_t
28672867
native clearscope int GetColorSet() const;
28682868
native clearscope int GetPlayerClassNum() const;
28692869
native clearscope int GetSkin() const;
2870+
native clearscope int GetSkinCount() const;
28702871
native clearscope bool GetNeverSwitch() const;
28712872
native clearscope int GetGender() const;
28722873
native clearscope int GetTeam() const;
@@ -2878,6 +2879,7 @@ struct PlayerInfo native play // self is what internally is known as player_t
28782879
native bool GetFViewBob() const;
28792880
native double GetStillBob() const;
28802881
native void SetFOV(float fov);
2882+
native int SetSkin(int skinIndex);
28812883
native clearscope bool GetClassicFlight() const;
28822884
native void SendPitchLimits();
28832885
native clearscope bool HasWeaponsInSlot(int slot) const;

0 commit comments

Comments
 (0)