From 5774e44ee3da3af2b8786335070b362348221cad Mon Sep 17 00:00:00 2001 From: Jon Heard Date: Sun, 28 Apr 2024 19:39:45 -0400 Subject: [PATCH] SetSkin and GetSkinCount added to PlayerInfo class --- src/playsim/p_user.cpp | 23 +++++++++++++++++++ wadsrc/static/zscript/actors/player/player.zs | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index 967ddb660a7..8fd91f1117b 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -514,6 +514,23 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetFOV) return 0; } +DEFINE_ACTION_FUNCTION(_PlayerInfo, SetSkin) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_t); + PARAM_INT(skinIndex); + if (skinIndex >= 0 && skinIndex < Skins.size()) + { + // commented code - cvar_set calls this automatically, along with saving the skin selection. + //self->userinfo.SkinNumChanged(skinIndex); + cvar_set("skin", Skins[skinIndex].Name.GetChars()); + ACTION_RETURN_INT(self->userinfo.GetSkin()); + } + else + { + ACTION_RETURN_INT(-1); + } +} + //=========================================================================== // // EnumColorsets @@ -766,6 +783,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetSkin) ACTION_RETURN_INT(self->userinfo.GetSkin()); } +DEFINE_ACTION_FUNCTION(_PlayerInfo, GetSkinCount) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_t); + ACTION_RETURN_INT(Skins.size()); +} + DEFINE_ACTION_FUNCTION(_PlayerInfo, GetGender) { PARAM_SELF_STRUCT_PROLOGUE(player_t); diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index fe56805d79b..a3612a6fc33 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -2866,6 +2866,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native clearscope int GetColorSet() const; native clearscope int GetPlayerClassNum() const; native clearscope int GetSkin() const; + native clearscope int GetSkinCount() const; native clearscope bool GetNeverSwitch() const; native clearscope int GetGender() const; native clearscope int GetTeam() const; @@ -2877,6 +2878,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native bool GetFViewBob() const; native double GetStillBob() const; native void SetFOV(float fov); + native int SetSkin(int skinIndex); native clearscope bool GetClassicFlight() const; native void SendPitchLimits(); native clearscope bool HasWeaponsInSlot(int slot) const;