Files
DarkflameServer/dGame/UserManager.h
HailStorm32 5d5bce53d0 feat: Add configurable restrictions for muted accounts (#1887)
* Add configurable restrictions for muted accounts

* switched to and updated GetRandomElement

* Update config option check

* implement cached config values for mute settings and update handlers

* Address review

* Update dGame/dComponents/PetComponent.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* Update dGame/dComponents/PetComponent.cpp

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>

* reduce if argument chain

---------

Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
2025-10-05 22:09:43 -05:00

66 lines
1.9 KiB
C++

#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();
}
return m_Address;
}
void Initialize();
~UserManager();
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();
std::string GetPredefinedName(uint32_t firstNameIndex, uint32_t middleNameIndex, uint32_t lastNameIndex);
bool IsNamePreapproved(const std::string& requestedName);
void RequestCharacterList(const SystemAddress& sysAddr);
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, LWOOBJID playerID);
void SaveAllActiveCharacters();
size_t GetUserCount() const { return m_Users.size(); }
// Access cached config values
bool GetMuteAutoRejectNames() const { return m_MuteAutoRejectNames; }
bool GetMuteRestrictTrade() const { return m_MuteRestrictTrade; }
bool GetMuteRestrictMail() const { return m_MuteRestrictMail; }
private:
static UserManager* m_Address; //Singleton
std::map<SystemAddress, User*> m_Users;
std::vector<User*> m_UsersToDelete;
std::vector<std::string> m_FirstNames;
std::vector<std::string> m_MiddleNames;
std::vector<std::string> m_LastNames;
std::vector<std::string> m_PreapprovedNames;
// Cached config values that can change on config reload
bool m_MuteAutoRejectNames = false;
bool m_MuteRestrictTrade = false;
bool m_MuteRestrictMail = false;
};
#endif // USERMANAGER_H