Skip to content

Commit ce9d55b

Browse files
committed
SetSkin and GetSkinCount added to PlayerInfo class
1 parent 4625d4a commit ce9d55b

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
@@ -508,6 +508,23 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetFOV)
508508
return 0;
509509
}
510510

511+
DEFINE_ACTION_FUNCTION(_PlayerInfo, SetSkin)
512+
{
513+
PARAM_SELF_STRUCT_PROLOGUE(player_t);
514+
PARAM_INT(skinIndex);
515+
if (skinIndex >= 0 && skinIndex < Skins.size())
516+
{
517+
// commented code - cvar_set calls this automatically, along with saving the skin selection.
518+
//self->userinfo.SkinNumChanged(skinIndex);
519+
cvar_set("skin", Skins[skinIndex].Name.GetChars());
520+
ACTION_RETURN_INT(self->userinfo.GetSkin());
521+
}
522+
else
523+
{
524+
ACTION_RETURN_INT(-1);
525+
}
526+
}
527+
511528
//===========================================================================
512529
//
513530
// EnumColorsets
@@ -760,6 +777,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetSkin)
760777
ACTION_RETURN_INT(self->userinfo.GetSkin());
761778
}
762779

780+
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetSkinCount)
781+
{
782+
PARAM_SELF_STRUCT_PROLOGUE(player_t);
783+
ACTION_RETURN_INT(Skins.size());
784+
}
785+
763786
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetGender)
764787
{
765788
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
@@ -2863,6 +2863,7 @@ struct PlayerInfo native play // self is what internally is known as player_t
28632863
native clearscope int GetColorSet() const;
28642864
native clearscope int GetPlayerClassNum() const;
28652865
native clearscope int GetSkin() const;
2866+
native clearscope int GetSkinCount() const;
28662867
native clearscope bool GetNeverSwitch() const;
28672868
native clearscope int GetGender() const;
28682869
native clearscope int GetTeam() const;
@@ -2874,6 +2875,7 @@ struct PlayerInfo native play // self is what internally is known as player_t
28742875
native bool GetFViewBob() const;
28752876
native double GetStillBob() const;
28762877
native void SetFOV(float fov);
2878+
native int SetSkin(int skinIndex);
28772879
native clearscope bool GetClassicFlight() const;
28782880
native void SendPitchLimits();
28792881
native clearscope bool HasWeaponsInSlot(int slot) const;

0 commit comments

Comments
 (0)