Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
91 lines
2.4 KiB
C++
91 lines
2.4 KiB
C++
#ifndef _GM_MANAGE_LIB_TOOL_USER_MANAGE_TABLE_H_
|
|
#define _GM_MANAGE_LIB_TOOL_USER_MANAGE_TABLE_H_
|
|
|
|
#include <list>
|
|
#include <Network/Packet/ManagePacketCmd.h>
|
|
|
|
// forward decl.
|
|
class CManageServerDB;
|
|
class CSession;
|
|
class CManageToolServerDispatch;
|
|
|
|
class CToolUserManager
|
|
{
|
|
public:
|
|
|
|
typedef std::list<ServerManage::UserInfo> UserList;
|
|
|
|
enum Level
|
|
{
|
|
MASTER = 0,
|
|
GENERAL = 1,
|
|
MONITORING = 2
|
|
};
|
|
|
|
static CToolUserManager& GetInstance();
|
|
|
|
// UserManagement ( Use File Database )
|
|
bool AddUser(const ServerManage::UserInfo& userInfo);
|
|
bool DelUser(const char* szID);
|
|
bool ModifyUser(const ServerManage::UserInfo& modified);
|
|
bool GetUserInfo(const char* szID_In, ServerManage::UserInfo& userInfo_Out);
|
|
bool GetUserInfo(UserList& userList_Out);
|
|
|
|
// Login/Logout (In Server)
|
|
ServerManage::UserCommandError Authorize(
|
|
CManageToolServerDispatch& dispatch,
|
|
ServerManage::UserInfo& userInfo_inout);
|
|
|
|
bool IsLogin(const char* szName);
|
|
bool Logout(const char* szName);
|
|
|
|
// Send packets to all users
|
|
bool SendToAllLoginUser(const char* szBuffer, unsigned short usBufferSize, unsigned char cCmd_In);
|
|
|
|
bool SendAllLoginUserInfo(CSession& Session);
|
|
bool SendAllUserInfo(CSession& Session);
|
|
|
|
// ProcessAll
|
|
template<typename FnProcess>
|
|
void ProcessCurrentUser(FnProcess fnProcess)
|
|
{
|
|
CurrentUserList::iterator pos = m_LoginUserList.begin();
|
|
CurrentUserList::iterator end = m_LoginUserList.end();
|
|
|
|
for(;pos != end; ++pos)
|
|
{
|
|
fnProcess(*pos->m_lpDispatch);
|
|
}
|
|
}
|
|
|
|
CManageToolServerDispatch* GetUserDispatch(unsigned long dwIP);
|
|
CManageToolServerDispatch* GetUserDispatch(const char* szID);
|
|
|
|
void Promote(const ServerManage::UserInfo& promoteUser) { m_ManageUser = promoteUser; }
|
|
|
|
bool IsManageUser(const ServerManage::UserInfo& UserInfo);
|
|
const ServerManage::UserInfo& GetManageUser() const { return m_ManageUser; }
|
|
CManageToolServerDispatch* GetManageUserDispatch() { return GetUserDispatch(m_ManageUser.szID); }
|
|
|
|
private:
|
|
|
|
CToolUserManager(CManageServerDB& ManageServerDB);
|
|
~CToolUserManager();
|
|
|
|
struct ToolUser
|
|
{
|
|
CManageToolServerDispatch* m_lpDispatch;
|
|
ServerManage::UserInfo m_UserInfo;
|
|
|
|
ToolUser();
|
|
ToolUser(CManageToolServerDispatch* lpDispatch, ServerManage::UserInfo& userInfo);
|
|
};
|
|
|
|
typedef std::list<ToolUser> CurrentUserList;
|
|
|
|
CManageServerDB& m_ManageServerDB;
|
|
CurrentUserList m_LoginUserList; // Logged user list;
|
|
ServerManage::UserInfo m_ManageUser; // Current master user list;
|
|
};
|
|
|
|
#endif |