Skip to content

Commit

Permalink
Refactor server CLuaTeamDefs (PR #3945)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico8340 authored Jan 10, 2025
1 parent f37bbad commit 74ffa1d
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 281 deletions.
17 changes: 7 additions & 10 deletions Server/mods/deathmatch/logic/CTeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "CTeam.h"
#include "CLogger.h"
#include "Utils.h"
#include "lua/LuaCommon.h"

CTeam::CTeam(CTeamManager* pTeamManager, CElement* pParent, const char* szName, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue)
: CElement(pParent)
Expand Down Expand Up @@ -118,19 +117,17 @@ void CTeam::RemoveAllPlayers()
m_Players.clear();
}

void CTeam::GetPlayers(lua_State* luaVM)
std::vector<CPlayer*> CTeam::GetPlayers() const
{
unsigned int uiIndex = 0;
list<CPlayer*>::const_iterator iter = m_Players.begin();
for (; iter != m_Players.end(); ++iter)
std::vector<CPlayer*> players;

for (auto iter = m_Players.begin(); iter != m_Players.end(); ++iter)
{
if (!(*iter)->IsBeingDeleted())
{
lua_pushnumber(luaVM, ++uiIndex);
lua_pushelement(luaVM, *iter);
lua_settable(luaVM, -3);
}
players.push_back(*iter);
}

return players;
}

void CTeam::GetColor(unsigned char& ucRed, unsigned char& ucGreen, unsigned char& ucBlue)
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CTeam.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CTeam final : public CElement
void AddPlayer(CPlayer* pPlayer, bool bChangePlayer = false);
void RemovePlayer(CPlayer* pPlayer, bool bChangePlayer = false);
void RemoveAllPlayers();
void GetPlayers(lua_State* luaVM);
std::vector<CPlayer*> GetPlayers() const;

void GetColor(unsigned char& ucRed, unsigned char& ucGreen, unsigned char& ucBlue);
void SetColor(unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue);
Expand Down
Loading

0 comments on commit 74ffa1d

Please sign in to comment.