mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
* Move account related functions from ObjectMgr to AccountMgr and drop duplicate function also.
This commit is contained in:
parent
fc79aa717a
commit
ad5f559dad
7 changed files with 41 additions and 53 deletions
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "AccountMgr.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Player.h"
|
||||
#include "Policies/SingletonImp.h"
|
||||
#include "Util.h"
|
||||
|
|
@ -79,7 +79,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
|
|||
uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER);
|
||||
|
||||
// kick if player currently
|
||||
if(Player* p = objmgr.GetPlayer(guid))
|
||||
if(Player* p = ObjectAccessor::FindPlayer(guid))
|
||||
{
|
||||
WorldSession* s = p->GetSession();
|
||||
s->KickPlayer(); // mark session to remove at next session list update
|
||||
|
|
@ -166,6 +166,32 @@ uint32 AccountMgr::GetId(std::string username)
|
|||
}
|
||||
}
|
||||
|
||||
uint32 AccountMgr::GetSecurity(uint32 acc_id)
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id);
|
||||
if(result)
|
||||
{
|
||||
uint32 sec = (*result)[0].GetUInt32();
|
||||
delete result;
|
||||
return sec;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AccountMgr::GetName(uint32 acc_id, std::string &name)
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id);
|
||||
if(result)
|
||||
{
|
||||
name = (*result)[0].GetCppString();
|
||||
delete result;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AccountMgr::CheckPassword(uint32 accid, std::string passwd)
|
||||
{
|
||||
normilizeString(passwd);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ class AccountMgr
|
|||
bool CheckPassword(uint32 accid, std::string passwd);
|
||||
|
||||
uint32 GetId(std::string username);
|
||||
uint32 GetIdByGUID(const uint64 &guid) const;
|
||||
uint32 GetSecurity(uint32 acc_id);
|
||||
bool GetName(uint32 acc_id, std::string &name);
|
||||
|
||||
static bool normilizeString(std::string& utf8str);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ bool ChatHandler::HandleMuteCommand(const char* args)
|
|||
else
|
||||
{
|
||||
account_id = objmgr.GetPlayerAccountIdByGUID(guid);
|
||||
security = objmgr.GetSecurityByAccount(account_id);
|
||||
security = accmgr.GetSecurity(account_id);
|
||||
}
|
||||
|
||||
if(security >= m_session->GetSecurity())
|
||||
|
|
@ -160,7 +160,7 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
|||
else
|
||||
{
|
||||
account_id = objmgr.GetPlayerAccountIdByGUID(guid);
|
||||
security = objmgr.GetSecurityByAccount(account_id);
|
||||
security = accmgr.GetSecurity(account_id);
|
||||
}
|
||||
|
||||
if(security >= m_session->GetSecurity())
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "PlayerDump.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Player.h"
|
||||
|
|
@ -711,7 +712,7 @@ bool ChatHandler::HandleSecurityCommand(const char* args)
|
|||
return false;
|
||||
}
|
||||
targetAccountId = objmgr.GetPlayerAccountIdByGUID(targetGUID);
|
||||
targetSecurity = objmgr.GetSecurityByAccount(targetAccountId);
|
||||
targetSecurity = accmgr.GetSecurity(targetAccountId);
|
||||
}
|
||||
|
||||
arg2 = strtok(NULL, " ");
|
||||
|
|
@ -4964,14 +4965,14 @@ bool ChatHandler::HandleLoadPDumpCommand(const char *args)
|
|||
if(!file || !acc)
|
||||
return false;
|
||||
|
||||
uint32 account_id = objmgr.GetAccountByAccountName(acc);
|
||||
uint32 account_id = accmgr.GetId(acc);
|
||||
if(!account_id)
|
||||
{
|
||||
account_id = atoi(acc);
|
||||
if(account_id)
|
||||
{
|
||||
std::string acc_name;
|
||||
if(!objmgr.GetAccountNameByAccount(account_id,acc_name))
|
||||
if(!accmgr.GetName(account_id,acc_name))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "GameEvent.h"
|
||||
#include "Spell.h"
|
||||
#include "Chat.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "Util.h"
|
||||
|
|
@ -317,7 +318,7 @@ void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction )
|
|||
else
|
||||
{
|
||||
bidder_accId = GetPlayerAccountIdByGUID(bidder_guid);
|
||||
bidder_security = GetSecurityByAccount(bidder_accId);
|
||||
bidder_security = accmgr.GetSecurity(bidder_accId);
|
||||
|
||||
if(bidder_security > SEC_PLAYER ) // not do redundant DB requests
|
||||
{
|
||||
|
|
@ -1295,46 +1296,6 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::GetSecurityByAccount(uint32 acc_id) const
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id);
|
||||
if(result)
|
||||
{
|
||||
uint32 sec = (*result)[0].GetUInt32();
|
||||
delete result;
|
||||
return sec;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ObjectMgr::GetAccountNameByAccount(uint32 acc_id, std::string &name) const
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id);
|
||||
if(result)
|
||||
{
|
||||
name = (*result)[0].GetCppString();
|
||||
delete result;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::GetAccountByAccountName(std::string name) const
|
||||
{
|
||||
loginDatabase.escape_string(name);
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", name.c_str());
|
||||
if(result)
|
||||
{
|
||||
uint32 id = (*result)[0].GetUInt32();
|
||||
delete result;
|
||||
return id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadAuctions()
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
|
||||
|
|
|
|||
|
|
@ -391,9 +391,6 @@ class ObjectMgr
|
|||
bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const;
|
||||
uint32 GetPlayerTeamByGUID(const uint64 &guid) const;
|
||||
uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const;
|
||||
uint32 GetSecurityByAccount(uint32 acc_id) const;
|
||||
bool GetAccountNameByAccount(uint32 acc_id, std::string &name) const;
|
||||
uint32 GetAccountByAccountName(std::string name) const;
|
||||
|
||||
uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid );
|
||||
void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost);
|
||||
|
|
|
|||
|
|
@ -166,14 +166,14 @@ void CliLoadPlayerDump(char*command,pPrintf zprintf)
|
|||
return;
|
||||
}
|
||||
|
||||
uint32 account_id = objmgr.GetAccountByAccountName(acc);
|
||||
uint32 account_id = accmgr.GetId(acc);
|
||||
if(!account_id)
|
||||
{
|
||||
account_id = atoi(acc);
|
||||
if(account_id)
|
||||
{
|
||||
std::string acc_name;
|
||||
if(!objmgr.GetAccountNameByAccount(account_id,acc_name))
|
||||
if(!accmgr.GetName(account_id,acc_name))
|
||||
{
|
||||
zprintf("Failed to load the character! Account not exist.\r\n");
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue