mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-05-22 04:58:21 +02:00
Store the owner UserManager in User.
This commit is contained in:
parent
5c752900dd
commit
066e88e336
@ -28,6 +28,9 @@
|
||||
um.module_name = "SomeUserModule"
|
||||
user.add_module(um)
|
||||
|
||||
# Only needed if the default implementation is not called
|
||||
#user.set_owner_user_manager(self)
|
||||
|
||||
return ._create_user(user)[/code]
|
||||
</description>
|
||||
</method>
|
||||
|
@ -81,6 +81,8 @@ Ref<User> UserManager::_create_user(Ref<User> p_user) {
|
||||
p_user.instance();
|
||||
}
|
||||
|
||||
p_user->set_owner_user_manager(this);
|
||||
|
||||
return p_user;
|
||||
}
|
||||
bool UserManager::_is_username_taken(const String &user_name) {
|
||||
|
@ -30,9 +30,10 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "user.h"
|
||||
#include "../managers/user_manager.h"
|
||||
#include "../singleton/user_db.h"
|
||||
#include "core/io/json.h"
|
||||
#include "core/object/class_db.h"
|
||||
#include "../singleton/user_db.h"
|
||||
|
||||
#include "user_module.h"
|
||||
|
||||
@ -324,11 +325,22 @@ Error User::write_try_lock() {
|
||||
return _rw_lock.write_try_lock();
|
||||
}
|
||||
|
||||
UserManager *User::get_owner_user_manager() {
|
||||
return _owner_user_manager;
|
||||
}
|
||||
void User::set_owner_user_manager(UserManager *p_user_manager) {
|
||||
_owner_user_manager = p_user_manager;
|
||||
}
|
||||
void User::set_owner_user_manager_bind(Node *p_user_manager) {
|
||||
set_owner_user_manager(Object::cast_to<UserManager>(p_user_manager));
|
||||
}
|
||||
|
||||
User::User() {
|
||||
_user_id = -1;
|
||||
_rank = 0;
|
||||
_banned = false;
|
||||
_locked = false;
|
||||
_owner_user_manager = NULL;
|
||||
}
|
||||
|
||||
User::~User() {
|
||||
@ -422,4 +434,8 @@ void User::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("write_unlock"), &User::write_unlock);
|
||||
ClassDB::bind_method(D_METHOD("read_try_lock"), &User::read_try_lock);
|
||||
ClassDB::bind_method(D_METHOD("write_try_lock"), &User::write_try_lock);
|
||||
|
||||
// No property. Changing this should not really happen normally, only during more advanced uses.
|
||||
ClassDB::bind_method(D_METHOD("get_owner_user_manager"), &User::get_owner_user_manager);
|
||||
ClassDB::bind_method(D_METHOD("set_owner_user_manager", "user_manager"), &User::set_owner_user_manager_bind);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "core/object/resource.h"
|
||||
|
||||
class UserModule;
|
||||
class UserManager;
|
||||
|
||||
class User : public Resource {
|
||||
GDCLASS(User, Resource);
|
||||
@ -108,6 +109,10 @@ public:
|
||||
Error read_try_lock();
|
||||
Error write_try_lock();
|
||||
|
||||
UserManager *get_owner_user_manager();
|
||||
void set_owner_user_manager(UserManager *p_user_manager);
|
||||
void set_owner_user_manager_bind(Node *p_user_manager);
|
||||
|
||||
User();
|
||||
~User();
|
||||
|
||||
@ -128,6 +133,8 @@ protected:
|
||||
Vector<Ref<UserModule>> _modules;
|
||||
|
||||
RWLock _rw_lock;
|
||||
|
||||
UserManager *_owner_user_manager;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user