Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new account events: onAccountCreate/onAccountRemove & new function getAccountType #3019

Merged
merged 16 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/CAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class CAccount
const SString& GetName() { return m_strName; }
void SetName(const std::string& strName);

EAccountType GetType() { return m_AccountType; }
TracerDS marked this conversation as resolved.
Show resolved Hide resolved

void SetPassword(const SString& strPassword);
bool IsPassword(const SString& strPassword, bool* pbUsedHttpPassAppend = nullptr);
SString GetPasswordHash();
Expand Down
16 changes: 16 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaAccountDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void CLuaAccountDefs::LoadFunctions()

// Account get functions
{"getAccountName", GetAccountName},
{"getAccountType", ArgumentParser<GetAccountType>},
{"getAccountPlayer", GetAccountPlayer},
{"isGuestAccount", IsGuestAccount},
{"getAccountData", GetAccountData},
Expand Down Expand Up @@ -77,6 +78,7 @@ void CLuaAccountDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "getData", "getAccountData");
lua_classfunction(luaVM, "getAllData", "getAllAccountData");
lua_classfunction(luaVM, "getName", "getAccountName");
lua_classfunction(luaVM, "getType", "getAccountType");
lua_classfunction(luaVM, "getPlayer", "getAccountPlayer");
lua_classfunction(luaVM, "isGuest", "isGuestAccount");

Expand Down Expand Up @@ -116,6 +118,20 @@ int CLuaAccountDefs::GetAccountName(lua_State* luaVM)
return 1;
}

std::optional<std::string> CLuaAccountDefs::GetAccountType(CAccount* pAccount)
{
switch (pAccount->GetType())
{
case EAccountType::Guest:
return "guest";
case EAccountType::Console:
return "console";
case EAccountType::Player:
return "player";
}
return {};
}

int CLuaAccountDefs::GetAccountPlayer(lua_State* luaVM)
{
// player getAccountPlayer ( account theAccount )
Expand Down
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaAccountDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class CLuaAccountDefs : public CLuaDefs
LUA_DECLARE(GetAccount);
LUA_DECLARE(GetAccounts);
LUA_DECLARE(GetAccountName);

static std::optional<std::string> GetAccountType(CAccount* pAccount);

LUA_DECLARE(GetAccountPlayer);
LUA_DECLARE(IsGuestAccount);
LUA_DECLARE(GetAccountData);
Expand Down