From e7dd7159b1e1ab5b3edabc44ece5338672f8fbb4 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Oct 2016 19:51:39 -0400 Subject: Make vhosts assignable to accounts, not nicks. Allow multiple vhosts per account. --- modules/hostserv/main/hostserv.cpp | 14 +++++--------- modules/hostserv/main/vhost.cpp | 14 ++++++++++++-- modules/hostserv/main/vhost.h | 4 ++++ modules/hostserv/main/vhosttype.cpp | 1 + modules/hostserv/main/vhosttype.h | 1 + 5 files changed, 23 insertions(+), 11 deletions(-) (limited to 'modules/hostserv/main') diff --git a/modules/hostserv/main/hostserv.cpp b/modules/hostserv/main/hostserv.cpp index ab1617a85..b0c3d04f2 100644 --- a/modules/hostserv/main/hostserv.cpp +++ b/modules/hostserv/main/hostserv.cpp @@ -66,14 +66,7 @@ class HostServCore : public Module if (!IRCD->CanSetVHost) return; - NickServ::Nick *na = NickServ::FindNick(u->nick); - HostServ::VHost *vhost = nullptr; - - if (na && na->GetAccount() == u->Account()) - vhost = na->GetVHost(); - - if (vhost == nullptr) - vhost = NickServ::FindNick(u->Account()->GetDisplay())->GetVHost(); + HostServ::VHost *vhost = HostServ::FindVHost(u->Account()); if (vhost == nullptr) return; @@ -123,7 +116,10 @@ class HostServCore : public Module if (u && u->Account() == na->GetAccount()) { - HostServ::VHost *vhost = na->GetVHost(); + HostServ::VHost *vhost = HostServ::FindVHost(u->Account()); + + if (vhost == nullptr) + return; IRCD->SendVhost(u, vhost->GetIdent(), vhost->GetHost()); diff --git a/modules/hostserv/main/vhost.cpp b/modules/hostserv/main/vhost.cpp index f7878d53c..635e3a5b4 100644 --- a/modules/hostserv/main/vhost.cpp +++ b/modules/hostserv/main/vhost.cpp @@ -1,7 +1,7 @@ /* * Anope IRC Services * - * Copyright (C) 2015-2016 Anope Team + * Copyright (C) 2016 Anope Team * * This file is part of Anope. Anope is free software; you can * redistribute it and/or modify it under the terms of the GNU @@ -67,4 +67,14 @@ time_t VHostImpl::GetCreated() void VHostImpl::SetCreated(time_t created) { Set(&VHostType::created, created); -} \ No newline at end of file +} + +bool VHostImpl::IsDefault() +{ + return Get(&VHostType::default_); +} + +void VHostImpl::SetDefault(bool default_) +{ + Set(&VHostType::default_, default_); +} diff --git a/modules/hostserv/main/vhost.h b/modules/hostserv/main/vhost.h index e0b751899..90ac9140f 100644 --- a/modules/hostserv/main/vhost.h +++ b/modules/hostserv/main/vhost.h @@ -30,6 +30,7 @@ class VHostImpl : public HostServ::VHost Anope::string vhost; Anope::string creator; time_t created = 0; + bool default_ = false; public: using HostServ::VHost::VHost; @@ -48,5 +49,8 @@ class VHostImpl : public HostServ::VHost time_t GetCreated() override; void SetCreated(time_t) override; + + bool IsDefault() override; + void SetDefault(bool) override; }; diff --git a/modules/hostserv/main/vhosttype.cpp b/modules/hostserv/main/vhosttype.cpp index 3eae8eec3..ee73840bf 100644 --- a/modules/hostserv/main/vhosttype.cpp +++ b/modules/hostserv/main/vhosttype.cpp @@ -26,6 +26,7 @@ VHostType::VHostType(Module *me) : Serialize::Type(me) , vhost(this, "vhost", &VHostImpl::vhost) , creator(this, "creator", &VHostImpl::creator) , created(this, "created", &VHostImpl::created) + , default_(this, "default", &VHostImpl::default_) { } diff --git a/modules/hostserv/main/vhosttype.h b/modules/hostserv/main/vhosttype.h index 8306cae27..3be60f518 100644 --- a/modules/hostserv/main/vhosttype.h +++ b/modules/hostserv/main/vhosttype.h @@ -27,6 +27,7 @@ class VHostType : public Serialize::Type Serialize::Field vhost; Serialize::Field creator; Serialize::Field created; + Serialize::Field default_; VHostType(Module *); }; -- cgit