Skip to content

Commit b0137e5

Browse files
Boondorlmadame-rachelle
authored andcommitted
Exported FTeam getters
1 parent f2d7bbe commit b0137e5

File tree

3 files changed

+88
-6
lines changed

3 files changed

+88
-6
lines changed

src/gamedata/teaminfo.cpp

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "gi.h"
3939

4040
#include "teaminfo.h"
41+
#include "texturemanager.h"
4142
#include "v_font.h"
4243
#include "v_video.h"
4344
#include "filesystem.h"
@@ -244,7 +245,7 @@ void FTeam::ClearTeams ()
244245
//
245246
//==========================================================================
246247

247-
bool FTeam::IsValidTeam (unsigned int uiTeam)
248+
bool FTeam::IsValidTeam (unsigned int uiTeam) const
248249
{
249250
if (uiTeam >= Teams.Size ())
250251
return false;
@@ -303,7 +304,7 @@ int FTeam::GetTextColor () const
303304
//
304305
//==========================================================================
305306

306-
FString FTeam::GetLogo () const
307+
const FString& FTeam::GetLogo () const
307308
{
308309
return m_Logo;
309310
}
@@ -338,3 +339,75 @@ CCMD (teamlist)
338339

339340
DEFINE_GLOBAL(Teams)
340341
DEFINE_FIELD_NAMED(FTeam, m_Name, mName)
342+
343+
static int IsValid(unsigned int id)
344+
{
345+
return TeamLibrary.IsValidTeam(id);
346+
}
347+
348+
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, IsValid, IsValid)
349+
{
350+
PARAM_PROLOGUE;
351+
PARAM_UINT(id);
352+
353+
ACTION_RETURN_BOOL(TeamLibrary.IsValidTeam(id));
354+
}
355+
356+
static int GetPlayerColor(FTeam* self)
357+
{
358+
return self->GetPlayerColor();
359+
}
360+
361+
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetPlayerColor, GetPlayerColor)
362+
{
363+
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
364+
ACTION_RETURN_INT(self->GetPlayerColor());
365+
}
366+
367+
static int GetTextColor(FTeam* self)
368+
{
369+
return self->GetTextColor();
370+
}
371+
372+
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetTextColor, GetTextColor)
373+
{
374+
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
375+
ACTION_RETURN_INT(self->GetTextColor());
376+
}
377+
378+
static int GetLogo(FTeam* self)
379+
{
380+
const FString& name = self->GetLogo();
381+
if (name.IsEmpty())
382+
return -1;
383+
384+
return TexMan.CheckForTexture(name.GetChars(), ETextureType::Any).GetIndex();
385+
}
386+
387+
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetLogo, GetLogo)
388+
{
389+
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
390+
ACTION_RETURN_INT(GetLogo(self));
391+
}
392+
393+
static void GetLogoName(FTeam* self, FString* res)
394+
{
395+
*res = self->GetLogo();
396+
}
397+
398+
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetLogoName, GetLogoName)
399+
{
400+
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
401+
ACTION_RETURN_STRING(self->GetLogo());
402+
}
403+
404+
static int AllowsCustomPlayerColor(FTeam* self)
405+
{
406+
return self->GetAllowCustomPlayerColor();
407+
}
408+
409+
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, AllowsCustomPlayerColor, AllowsCustomPlayerColor)
410+
{
411+
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
412+
ACTION_RETURN_BOOL(self->GetAllowCustomPlayerColor());
413+
}

src/gamedata/teaminfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class FTeam
4646
public:
4747
FTeam ();
4848
void ParseTeamInfo ();
49-
bool IsValidTeam (unsigned int uiTeam);
49+
bool IsValidTeam (unsigned int uiTeam) const;
5050

5151
const char *GetName () const;
5252
int GetPlayerColor () const;
5353
int GetTextColor () const;
54-
FString GetLogo () const;
54+
const FString& GetLogo () const;
5555
bool GetAllowCustomPlayerColor () const;
5656

5757
int m_iPlayerCount;

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,7 +2969,16 @@ struct PlayerSkin native
29692969

29702970
struct Team native
29712971
{
2972-
const NoTeam = 255;
2973-
const Max = 16;
2972+
const NOTEAM = 255;
2973+
const MAX = 16;
2974+
29742975
native String mName;
2976+
2977+
native static bool IsValid(uint teamIndex);
2978+
2979+
native Color GetPlayerColor() const;
2980+
native int GetTextColor() const;
2981+
native TextureID GetLogo() const;
2982+
native string GetLogoName() const;
2983+
native bool AllowsCustomPlayerColor() const;
29752984
}

0 commit comments

Comments
 (0)