2021-12-05 17:54:36 +00:00
|
|
|
#ifndef USERMANAGER_H
|
|
|
|
#define USERMANAGER_H
|
|
|
|
|
|
|
|
#define _VARIADIC_MAX 10
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "RakNetTypes.h"
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
class User;
|
|
|
|
|
|
|
|
class UserManager {
|
|
|
|
public:
|
|
|
|
static UserManager* Instance() {
|
|
|
|
if (!m_Address) {
|
|
|
|
m_Address = new UserManager();
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
return m_Address;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
void Initialize();
|
|
|
|
~UserManager();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
User* CreateUser(const SystemAddress& sysAddr, const std::string& username, const std::string& sessionKey);
|
|
|
|
User* GetUser(const SystemAddress& sysAddr);
|
|
|
|
User* GetUser(const std::string& username);
|
|
|
|
bool DeleteUser(const SystemAddress& sysAddr); //Returns true on succesful deletion
|
|
|
|
void DeletePendingRemovals();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
std::string GetPredefinedName(uint32_t firstNameIndex, uint32_t middleNameIndex, uint32_t lastNameIndex);
|
|
|
|
bool IsNamePreapproved(const std::string& requestedName);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
void RequestCharacterList(const SystemAddress& sysAddr);
|
2021-12-26 13:45:21 +00:00
|
|
|
void CreateCharacter(const SystemAddress& sysAddr, Packet* packet);
|
|
|
|
void DeleteCharacter(const SystemAddress& sysAddr, Packet* packet);
|
|
|
|
void RenameCharacter(const SystemAddress& sysAddr, Packet* packet);
|
|
|
|
void LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void SaveAllActiveCharacters();
|
|
|
|
|
|
|
|
size_t GetUserCount() const { return m_Users.size(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
static UserManager* m_Address; //Singleton
|
|
|
|
std::map<SystemAddress, User*> m_Users;
|
|
|
|
std::vector<User*> m_UsersToDelete;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-26 13:45:21 +00:00
|
|
|
std::vector<std::string> m_FirstNames;
|
|
|
|
std::vector<std::string> m_MiddleNames;
|
|
|
|
std::vector<std::string> m_LastNames;
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<std::string> m_PreapprovedNames;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // USERMANAGER_H
|