Skip to content

Commit

Permalink
Exported FTeam getters
Browse files Browse the repository at this point in the history
  • Loading branch information
Boondorl authored and madame-rachelle committed Apr 21, 2024
1 parent f2d7bbe commit b0137e5
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 6 deletions.
77 changes: 75 additions & 2 deletions src/gamedata/teaminfo.cpp
Expand Up @@ -38,6 +38,7 @@
#include "gi.h"

#include "teaminfo.h"
#include "texturemanager.h"
#include "v_font.h"
#include "v_video.h"
#include "filesystem.h"
Expand Down Expand Up @@ -244,7 +245,7 @@ void FTeam::ClearTeams ()
//
//==========================================================================

bool FTeam::IsValidTeam (unsigned int uiTeam)
bool FTeam::IsValidTeam (unsigned int uiTeam) const
{
if (uiTeam >= Teams.Size ())
return false;
Expand Down Expand Up @@ -303,7 +304,7 @@ int FTeam::GetTextColor () const
//
//==========================================================================

FString FTeam::GetLogo () const
const FString& FTeam::GetLogo () const
{
return m_Logo;
}
Expand Down Expand Up @@ -338,3 +339,75 @@ CCMD (teamlist)

DEFINE_GLOBAL(Teams)
DEFINE_FIELD_NAMED(FTeam, m_Name, mName)

static int IsValid(unsigned int id)
{
return TeamLibrary.IsValidTeam(id);
}

DEFINE_ACTION_FUNCTION_NATIVE(FTeam, IsValid, IsValid)
{
PARAM_PROLOGUE;
PARAM_UINT(id);

ACTION_RETURN_BOOL(TeamLibrary.IsValidTeam(id));
}

static int GetPlayerColor(FTeam* self)
{
return self->GetPlayerColor();
}

DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetPlayerColor, GetPlayerColor)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_INT(self->GetPlayerColor());
}

static int GetTextColor(FTeam* self)
{
return self->GetTextColor();
}

DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetTextColor, GetTextColor)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_INT(self->GetTextColor());
}

static int GetLogo(FTeam* self)
{
const FString& name = self->GetLogo();
if (name.IsEmpty())
return -1;

return TexMan.CheckForTexture(name.GetChars(), ETextureType::Any).GetIndex();
}

DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetLogo, GetLogo)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_INT(GetLogo(self));
}

static void GetLogoName(FTeam* self, FString* res)
{
*res = self->GetLogo();
}

DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetLogoName, GetLogoName)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_STRING(self->GetLogo());
}

static int AllowsCustomPlayerColor(FTeam* self)
{
return self->GetAllowCustomPlayerColor();
}

DEFINE_ACTION_FUNCTION_NATIVE(FTeam, AllowsCustomPlayerColor, AllowsCustomPlayerColor)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_BOOL(self->GetAllowCustomPlayerColor());
}
4 changes: 2 additions & 2 deletions src/gamedata/teaminfo.h
Expand Up @@ -46,12 +46,12 @@ class FTeam
public:
FTeam ();
void ParseTeamInfo ();
bool IsValidTeam (unsigned int uiTeam);
bool IsValidTeam (unsigned int uiTeam) const;

const char *GetName () const;
int GetPlayerColor () const;
int GetTextColor () const;
FString GetLogo () const;
const FString& GetLogo () const;
bool GetAllowCustomPlayerColor () const;

int m_iPlayerCount;
Expand Down
13 changes: 11 additions & 2 deletions wadsrc/static/zscript/actors/player/player.zs
Expand Up @@ -2969,7 +2969,16 @@ struct PlayerSkin native

struct Team native
{
const NoTeam = 255;
const Max = 16;
const NOTEAM = 255;
const MAX = 16;

native String mName;

native static bool IsValid(uint teamIndex);

native Color GetPlayerColor() const;
native int GetTextColor() const;
native TextureID GetLogo() const;
native string GetLogoName() const;
native bool AllowsCustomPlayerColor() const;
}

0 comments on commit b0137e5

Please sign in to comment.