Skip to content

Commit

Permalink
createTeam arguments fix (#3949)
Browse files Browse the repository at this point in the history
* createTeam default arguments fix

* Colors according to the previous code
  • Loading branch information
tederis authored Jan 11, 2025
1 parent d94d559 commit e9ec7f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/luadefs/CLuaTeamDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ void CLuaTeamDefs::AddClass(lua_State* luaVM)
lua_registerclass(luaVM, "Team", "Element");
}

std::variant<CTeam*, bool> CLuaTeamDefs::CreateTeam(lua_State* lua, const std::string name, const std::uint8_t red, const std::uint8_t green, const std::uint8_t blue)
std::variant<CTeam*, bool> CLuaTeamDefs::CreateTeam(lua_State* lua, const std::string name, const std::optional<std::uint8_t> red, const std::optional<std::uint8_t> green, const std::optional<std::uint8_t> blue)
{
CLuaMain& vm = lua_getownercluamain(lua);
CResource* resource = vm.GetResource();

if (!resource)
return false;

CTeam* team = CStaticFunctionDefinitions::CreateTeam(resource, name.c_str(), red, green, blue);
CTeam* team = CStaticFunctionDefinitions::CreateTeam(resource, name.c_str(), red.value_or(235), green.value_or(221), blue.value_or(178));

if (!team)
return false;
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaTeamDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CLuaTeamDefs : public CLuaDefs

private:
// Team create/destroy functions
static std::variant<CTeam*, bool> CreateTeam(lua_State* lua, const std::string name, const std::uint8_t red, const std::uint8_t green, const std::uint8_t blue);
static std::variant<CTeam*, bool> CreateTeam(lua_State* lua, const std::string name, const std::optional<std::uint8_t> red, const std::optional<std::uint8_t> green, const std::optional<std::uint8_t> blue);

// Team get funcs
static std::variant<CTeam*, bool> GetTeamFromName(const std::string name);
Expand Down

0 comments on commit e9ec7f1

Please sign in to comment.