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

✨ feat: add setAccountSerial #3587

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
67645e0
:sparkles: feat: add setAccountSerial
camargo2019 Jul 19, 2024
1b05f78
:safety_vest: fix: get account name validation
camargo2019 Jul 20, 2024
62ebf06
:adhesive_bandage: fix: using new ArgumentParser
camargo2019 Jul 20, 2024
9ad1188
:adhesive_bandage: fix: removing hungarian notation
camargo2019 Jul 20, 2024
be766cf
:safety_vest: fix: serial validation
camargo2019 Jul 20, 2024
7418e4c
:adhesive_bandage: fix: removing setSerial from OOP
camargo2019 Jul 20, 2024
3bdd277
:adhesive_bandage: fix: using noexcept in accounts
camargo2019 Jul 20, 2024
790ffa2
:adhesive_bandage: fix: using CAccount
camargo2019 Jul 20, 2024
9a14e49
:adhesive_bandage: fix: add try catch in IsValidSerial
camargo2019 Jul 20, 2024
94ac014
:adhesive_bandage: fix: const noexcept
camargo2019 Jul 20, 2024
776b75c
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Jul 21, 2024
63baddc
:adhesive_bandage: fix: add setAccountSerial in acl.xml
camargo2019 Jul 21, 2024
208e646
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Jul 23, 2024
7928ea7
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Jul 23, 2024
ccf6721
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Jul 29, 2024
ded288e
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Jul 31, 2024
3bd593e
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Aug 1, 2024
fc58764
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Aug 2, 2024
fff2726
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Aug 6, 2024
c207fd9
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Aug 13, 2024
a244c0a
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Aug 17, 2024
03ea71f
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Aug 29, 2024
e3b8897
:adhesive_bandage: fix: moving setAccountSerial to SuperModerator
camargo2019 Aug 29, 2024
43d8dbd
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Sep 2, 2024
09a022f
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Sep 3, 2024
a45cfaf
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Sep 4, 2024
bafa2cf
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Sep 4, 2024
eb0578a
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Sep 5, 2024
70e7493
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Sep 8, 2024
58c433a
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Sep 10, 2024
b16e2f3
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Sep 30, 2024
0d784fa
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Oct 5, 2024
2e5f55e
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Oct 7, 2024
37a8992
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Oct 14, 2024
0a9744f
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Oct 16, 2024
7ef6d6d
Merge branch 'master' into feat/add-set-account-serial
camargo2019 Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Server/mods/deathmatch/logic/CAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ bool CAccount::RemoveSerial(const SString& strSerial)
return false;
}

//
// Replace the serial number for a specific account
//
void CAccount::SetAccountSerial(const std::string strSerial)
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
{
m_strSerial = strSerial;
m_pManager->MarkAsChanged(this);
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
}

//
// Cleanup unauthorized serials
//
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class CAccount
bool AuthorizeSerial(const SString& strSerial, const SString& strWho);
bool RemoveSerial(const SString& strSerial);
void RemoveUnauthorizedSerials();
void SetAccountSerial(const std::string strSerial);
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved

CClient* GetClient() const { return m_pClient; }
void SetClient(CClient* pClient);
Expand Down
16 changes: 16 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11400,6 +11400,22 @@ bool CStaticFunctionDefinitions::GetAccountSerial(CAccount* pAccount, SString& s
return bRegistered;
}


bool CStaticFunctionDefinitions::SetAccountSerial(std::string strName, std::string strSerial)
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
{
const char* szAccountName = strName.c_str();
CAccount* pAccount = g_pGame->GetAccountManager()->Get(szAccountName);

if (!pAccount)
return false;

bool bRegistered = pAccount->IsRegistered();
if (bRegistered)
pAccount->SetAccountSerial(strSerial);

return bRegistered;
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
}
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved

bool CStaticFunctionDefinitions::GetAccountsBySerial(const SString& strSerial, std::vector<CAccount*>& outAccounts)
{
m_pAccountManager->GetAccountsBySerial(strSerial, outAccounts);
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ class CStaticFunctionDefinitions
// Account set funcs
static CAccount* AddAccount(const SString& strName, const SString& strPassword, bool bAllowCaseVariations, SString& strOutError);
static bool RemoveAccount(CAccount* pAccount);
static bool SetAccountSerial(std::string strName, std::string strSerial);
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
static bool SetAccountName(CAccount* pAccount, SString strNewName, bool bAllowCaseVariations, SString& strOutError);
static bool SetAccountPassword(CAccount* pAccount, SString szPassword, CAccountPassword::EAccountPasswordType ePasswordType);
static bool SetAccountData(CAccount* pAccount, const char* szKey, CLuaArgument* pArgument);
Expand Down
13 changes: 13 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaAccountDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void CLuaAccountDefs::LoadFunctions()
{"addAccount", AddAccount},
{"removeAccount", RemoveAccount},
{"setAccountPassword", SetAccountPassword},
{"setAccountSerial", ArgumentParser<SetAccountSerial>},
{"setAccountData", SetAccountData},
{"setAccountName", SetAccountName},
{"copyAccountData", CopyAccountData},
Expand Down Expand Up @@ -70,6 +71,7 @@ void CLuaAccountDefs::AddClass(lua_State* luaVM)

lua_classfunction(luaVM, "setData", "setAccountData");
lua_classfunction(luaVM, "setPassword", "setAccountPassword");
lua_classfunction(luaVM, "setSerial", "setAccountSerial");
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
lua_classfunction(luaVM, "setName", "setAccountName");

lua_classfunction(luaVM, "getSerial", "getAccountSerial");
Expand Down Expand Up @@ -513,6 +515,17 @@ int CLuaAccountDefs::RemoveAccount(lua_State* luaVM)
return 1;
}

bool CLuaAccountDefs::SetAccountSerial(std::string strName, std::string strSerial)
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
{
if (CStaticFunctionDefinitions::SetAccountSerial(strName, strSerial))
{
return true;
}

return false;
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
}


camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
int CLuaAccountDefs::SetAccountName(lua_State* luaVM)
{
// bool setAccountPassword ( account theAccount, string name[, bool allowCaseVariations = false ] )
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaAccountDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ class CLuaAccountDefs : public CLuaDefs
LUA_DECLARE(SetAccountPassword);
LUA_DECLARE(SetAccountData);
LUA_DECLARE(CopyAccountData);
static bool SetAccountSerial(std::string strName, std::string strSerial);
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
camargo2019 marked this conversation as resolved.
Show resolved Hide resolved
};