void Box2DPhysics::AddBox(std::shared_ptr<Actor> actor, float density, std::string type, bool fixedRotation, bool isSensor, float hitboxScale) { b2BodyDef bodyDef; bodyDef.position.Set(PixelsToMeters(actor->GetPosition().x + actor->GetScale().x * 0.5), PixelsToMeters(actor->GetPosition().y + actor->GetScale().y * 0.5)); // position should be center of object instead of top-left if (type == "dynamic") bodyDef.type = b2_dynamicBody; else if (type == "kinematic") bodyDef.type = b2_kinematicBody; bodyDef.fixedRotation = fixedRotation; b2Body* body = m_World->CreateBody(&bodyDef); BodyUserData *userData = new BodyUserData; userData->Physics = this; userData->Type = actor->GetType(); body->SetUserData((void*)userData); b2PolygonShape shape; shape.SetAsBox(PixelsToMeters(hitboxScale * actor->GetScale().x * 0.5), PixelsToMeters(hitboxScale * actor->GetScale().y * 0.5)); b2FixtureDef fixture; fixture.shape = &shape; fixture.density = density; fixture.isSensor = isSensor; body->CreateFixture(&fixture); m_BodyToActorID[body] = actor->GetID(); m_ActorIDToBody[actor->GetID()] = body; }
bool PreSaveLimitationsCheck::CheckLimitations(PersistenceMode mode, std::shared_ptr<DomainAlias> domainAlias, String &resultDescription) { if (mode == PersistenceModeRestore) return true; std::shared_ptr<const Domain> pDomain = CacheContainer::Instance()->GetDomain(domainAlias->GetName()); if (pDomain) { resultDescription = "Another domain with this name already exists."; return false; } // Check if there's a domain alias with this name. If so, this domain would be a duplciate. std::shared_ptr<DomainAliases> pDomainAliases = ObjectCache::Instance()->GetDomainAliases(); std::shared_ptr<DomainAlias> pDomainAlias = pDomainAliases->GetItemByName(domainAlias->GetName()); if (pDomainAlias && (domainAlias->GetID() == 0 || domainAlias->GetID() != pDomainAlias->GetID())) { resultDescription = "A domain alias with this name already exists."; return false; } return true; }
void Box2DPhysics::AddPolygon(std::shared_ptr<Actor> actor, std::vector<glm::vec2> vertices, float density, bool dynamic, bool fixedRotation) { b2BodyDef bodyDef; bodyDef.position.Set(PixelsToMeters(actor->GetPosition().x + actor->GetScale().x * 0.5), PixelsToMeters(actor->GetPosition().y + actor->GetScale().y * 0.5)); // position should be center of object instead of top-left if(dynamic) bodyDef.type = b2_dynamicBody; bodyDef.fixedRotation = fixedRotation; b2Body* body = m_World->CreateBody(&bodyDef); BodyUserData *userData = new BodyUserData; userData->Physics = this; userData->Type = actor->GetType(); body->SetUserData((void*)userData); // create 8 vertices b2Vec2 verts[8]; for(unsigned int i = 0; i < vertices.size(); ++i) verts[i].Set(PixelsToMeters(vertices[i].x * actor->GetScale().x * 0.5), PixelsToMeters(vertices[i].y * actor->GetScale().y * 0.5)); b2PolygonShape shape; shape.Set(verts, 8); b2FixtureDef fixture; fixture.shape = &shape; fixture.density = density; body->CreateFixture(&fixture); m_BodyToActorID[body] = actor->GetID(); m_ActorIDToBody[actor->GetID()] = body; }
bool PersistentFetchAccountUID::SaveObject(std::shared_ptr<FetchAccountUID> pUID, String &result, PersistenceMode mode) { SQLStatement oStatement; oStatement.SetTable("hm_fetchaccounts_uids"); oStatement.AddColumnInt64("uidfaid", pUID->GetAccountID()); oStatement.AddColumn("uidvalue", pUID->GetUID()); oStatement.AddColumnDate("uidtime", pUID->GetCreationDate()); if (pUID->GetID() == 0) { oStatement.SetStatementType(SQLStatement::STInsert); oStatement.SetIdentityColumn("uidid"); } else { oStatement.SetStatementType(SQLStatement::STUpdate); oStatement.SetWhereClause(Formatter::Format("uidid = {0}", pUID->GetID())); } bool bNewObject = pUID->GetID() == 0; // Save and fetch ID __int64 iDBID = 0; bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0); if (bRetVal && bNewObject) pUID->SetID((int) iDBID); return bRetVal; }
/* Deletes a specific IMAP folder. If forceDelete is false, the user Inbox won't be deleted. */ bool PersistentIMAPFolder::DeleteObject(std::shared_ptr<IMAPFolder> pFolder, bool forceDelete) { if (pFolder->GetID() <= 0) return false; // Delete sub folders first... if (!pFolder->GetSubFolders()->DeleteAll()) return false; // We must delete all email in this folder. pFolder->GetMessages()->Refresh(); pFolder->GetMessages()->DeleteMessages(); if (!pFolder->GetPermissions()->DeleteAll()) return false; bool isInbox = pFolder->GetParentFolderID() == -1 && pFolder->GetFolderName().CompareNoCase(_T("Inbox")) == 0; bool deleteActualFolder = forceDelete || !isInbox; if (deleteActualFolder) { SQLCommand command("delete from hm_imapfolders where folderid = @FOLDERID"); command.AddParameter("@FOLDERID", pFolder->GetID()); bool result = Application::Instance()->GetDBManager()->Execute(command); return result; } else return true; }
bool PersistentTCPIPPort::SaveObject(std::shared_ptr<TCPIPPort> pObject, String &errorMessage, PersistenceMode mode) { if (mode == PersistenceModeNormal) { if (pObject->GetSSLCertificateID() == 0 && (pObject->GetConnectionSecurity() == CSSSL || pObject->GetConnectionSecurity() == CSSTARTTLSOptional || pObject->GetConnectionSecurity() == CSSTARTTLSRequired)) { errorMessage = "Certificate must be specified."; return false; } } SQLStatement oStatement; oStatement.SetTable("hm_tcpipports"); if (pObject->GetID() == 0) { oStatement.SetStatementType(SQLStatement::STInsert); oStatement.SetIdentityColumn("portid"); } else { oStatement.SetStatementType(SQLStatement::STUpdate); String sWhere; sWhere.Format(_T("portid = %I64d"), pObject->GetID()); oStatement.SetWhereClause(sWhere); } __int64 iAddress = 0; IPAddressSQLHelper helper; oStatement.AddColumn("portprotocol", pObject->GetProtocol()); oStatement.AddColumn("portnumber", pObject->GetPortNumber()); oStatement.AddColumnInt64("portsslcertificateid", pObject->GetSSLCertificateID()); helper.AppendStatement(oStatement, pObject->GetAddress(), "portaddress1", "portaddress2"); oStatement.AddColumn("portconnectionsecurity", pObject->GetConnectionSecurity()); bool bNewObject = pObject->GetID() == 0; // Save and fetch ID __int64 iDBID = 0; bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0); if (bRetVal && bNewObject) pObject->SetID((int) iDBID); return true; }
void Box2DPhysics::AddCharacter(std::shared_ptr<Actor> actor, float density) { b2BodyDef bodyDef; bodyDef.position.Set(PixelsToMeters(actor->GetPosition().x + actor->GetScale().x * 0.5), PixelsToMeters(actor->GetPosition().y + actor->GetScale().y * 0.5)); // position should be center of object instead of top-left bodyDef.type = b2_dynamicBody; bodyDef.fixedRotation = true; bodyDef.allowSleep = false; b2Body* body = m_World->CreateBody(&bodyDef); body->SetBullet(true); BodyUserData *userData = new BodyUserData; userData->Physics = this; userData->Type = actor->GetType(); body->SetUserData((void*)userData); // Create box top-shape b2PolygonShape boxShape; b2Vec2 vertices[4]; vertices[0].Set(PixelsToMeters(-actor->GetScale().x * 0.2), PixelsToMeters(-actor->GetScale().y * 0.5)); vertices[1].Set(PixelsToMeters(-actor->GetScale().x * 0.2), PixelsToMeters(actor->GetScale().y * 0.2)); vertices[2].Set(PixelsToMeters(actor->GetScale().x * 0.2), PixelsToMeters(actor->GetScale().y * 0.2)); vertices[3].Set(PixelsToMeters(actor->GetScale().x * 0.2), PixelsToMeters(-actor->GetScale().y * 0.5)); boxShape.Set(vertices, 4); b2FixtureDef fixture; fixture.shape = &boxShape; fixture.density = density; fixture.friction = 0.95f; body->CreateFixture(&fixture); // Create circle bottom-shape b2CircleShape circleShape; circleShape.m_p.Set(0.0f, PixelsToMeters(actor->GetScale().y * 0.46 - actor->GetScale().x * 0.20)); circleShape.m_radius = PixelsToMeters(actor->GetScale().x * 0.23); b2FixtureDef fixture2; fixture2.shape = &circleShape; fixture2.density = density; fixture2.friction = 1.9f; body->CreateFixture(&fixture2); // Create bottom sensor to detect floor-collisions b2PolygonShape sensorShape; b2Vec2 origin = b2Vec2(0.0, PixelsToMeters(actor->GetScale().y * 0.44)); sensorShape.SetAsBox(PixelsToMeters(actor->GetScale().x * 0.05), PixelsToMeters(actor->GetScale().y * 0.05), origin, 0.0f); b2FixtureDef fixture3; fixture3.shape = &sensorShape; fixture3.isSensor = true; body->CreateFixture(&fixture3); m_BodyToActorID[body] = actor->GetID(); m_ActorIDToBody[actor->GetID()] = body; }
bool PersistentRoute::DeleteObject(std::shared_ptr<Route> pRoute) { if (pRoute->GetID() == 0) return false; // First delete the route addresses PersistentRouteAddress::DeleteByRoute(pRoute->GetID()); // Delete the route object itself. SQLCommand command("delete from hm_routes where routeid = @ROUTEID"); command.AddParameter("@ROUTEID", pRoute->GetID()); return Application::Instance()->GetDBManager()->Execute(command); }
bool PersistentAccount::DeleteMessages(std::shared_ptr<Account> pAccount) { if (!pAccount || pAccount->GetID() == 0) return false; PersistentIMAPFolder::DeleteByAccount(pAccount->GetID()); Cache<Account, PersistentAccount>::Instance()->RemoveObject(pAccount); AccountSizeCache::Instance()->Reset(pAccount->GetID()); IMAPFolderContainer::Instance()->UncacheAccount(pAccount->GetID()); return true; }
bool PersistentIMAPFolder::SaveObject(std::shared_ptr<IMAPFolder> pFolder) { bool bNewObject = true; if (pFolder->GetID()) bNewObject = false; SQLStatement oStatement; oStatement.SetTable("hm_imapfolders"); if (bNewObject) { oStatement.SetStatementType(SQLStatement::STInsert); oStatement.SetIdentityColumn("folderid"); DateTime creationTime = pFolder->GetCreationTime(); if (pFolder->GetCreationTime().GetStatus() == DateTime::invalid) pFolder->SetCreationTime(DateTime::GetCurrentTime()); // This column is always updated by GetUniqueMessageID below // but we still need to create it. oStatement.AddColumn("foldercurrentuid", pFolder->GetCurrentUID()); oStatement.AddColumnDate("foldercreationtime", pFolder->GetCreationTime()); } else { oStatement.SetStatementType(SQLStatement::STUpdate); String sWhere; sWhere.Format(_T("folderid = %I64d"), pFolder->GetID()); oStatement.SetWhereClause(sWhere); } oStatement.AddColumnInt64("folderaccountid", pFolder->GetAccountID()); oStatement.AddColumnInt64("folderparentid", pFolder->GetParentFolderID()); oStatement.AddColumn("foldername", pFolder->GetFolderName()); oStatement.AddColumn("folderissubscribed", pFolder->GetIsSubscribed() ? 1 : 0); __int64 iDBID = 0; bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0); if (bRetVal && bNewObject) pFolder->SetID((int) iDBID); return true; }
bool PersistentRoute::SaveObject(std::shared_ptr<Route> pRoute, String &sErrorMessage, PersistenceMode mode) { if (!PreSaveLimitationsCheck::CheckLimitations(mode, pRoute, sErrorMessage)) return false; SQLStatement oStatement; oStatement.SetTable("hm_routes"); oStatement.AddColumn("routedomainname", pRoute->DomainName()); oStatement.AddColumn("routedescription", pRoute->GetDescription()); oStatement.AddColumn("routetargetsmthost", pRoute->TargetSMTPHost()); oStatement.AddColumn("routetargetsmtport", pRoute->TargetSMTPPort()); oStatement.AddColumn("routenooftries", pRoute->NumberOfTries()); oStatement.AddColumn("routeminutesbetweentry", pRoute->MinutesBetweenTry()); oStatement.AddColumn("routealladdresses", pRoute->ToAllAddresses() ? 1 : 0); oStatement.AddColumn("routeuseauthentication", pRoute->GetRelayerRequiresAuth() ? 1 : 0); oStatement.AddColumn("routeauthenticationusername", pRoute->GetRelayerAuthUsername()); oStatement.AddColumn("routeauthenticationpassword", Crypt::Instance()->EnCrypt(pRoute->GetRelayerAuthPassword(), Crypt::ETBlowFish)); oStatement.AddColumn("routetreatsecurityaslocal", pRoute->GetTreatRecipientAsLocalDomain() ? 1 : 0); oStatement.AddColumn("routetreatsenderaslocaldomain", pRoute->GetTreatSenderAsLocalDomain() ? 1 : 0); oStatement.AddColumn("routeconnectionsecurity", pRoute->GetConnectionSecurity() ); if (pRoute->GetID() == 0) { oStatement.SetStatementType(SQLStatement::STInsert); oStatement.SetIdentityColumn("routeid"); } else { oStatement.SetStatementType(SQLStatement::STUpdate); String sWhere; sWhere.Format(_T("routeid = %I64d"), pRoute->GetID()); oStatement.SetWhereClause(sWhere); } bool bNewObject = pRoute->GetID() == 0; // Save and fetch ID __int64 iDBID = 0; bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0); if (bRetVal && bNewObject) pRoute->SetID((int) iDBID); return true; }
void LoginState::processUsername(const std::string &input, std::shared_ptr<Connection> connection) { connection->SetUsername(input); auto accounts = game_data->GetAccounts(); if(accounts.IsAccount(input)) { Sender::Send("Password: \r\n", connection); connection->SetAccount(accounts.GetAccount(input)); m_state_map[connection->GetID()] = PASSWORD; } else { Sender::Send("No account found, would you like to make a new one? Y/N\r\n", connection); m_state_map[connection->GetID()] = NEWACCOUNT; } }
bool PreSaveLimitationsCheck::CheckLimitations(PersistenceMode mode, std::shared_ptr<Group> group, String &resultDescription) { if (mode == PersistenceModeRestore) return true; std::shared_ptr<Group> pGroup = Configuration::Instance()->GetIMAPConfiguration()->GetGroups()->GetItemByName(group->GetName()); if (pGroup && (group->GetID() == 0 || group->GetID() != pGroup->GetID())) { resultDescription = "Another group with this name already exists."; return false; } return true; }
bool Events::FireOnDeliveryStart(std::shared_ptr<Message> pMessage) { if (!Configuration::Instance()->GetUseScriptServer()) return true; std::shared_ptr<ScriptObjectContainer> pContainer = std::shared_ptr<ScriptObjectContainer>(new ScriptObjectContainer); std::shared_ptr<Result> pResult = std::shared_ptr<Result>(new Result); pContainer->AddObject("HMAILSERVER_MESSAGE", pMessage, ScriptObject::OTMessage); pContainer->AddObject("Result", pResult, ScriptObject::OTResult); String sEventCaller = "OnDeliveryStart(HMAILSERVER_MESSAGE)"; ScriptServer::Instance()->FireEvent(ScriptServer::EventOnDeliveryStart, sEventCaller, pContainer); switch (pResult->GetValue()) { case 1: { String sMessage; sMessage.Format(_T("SMTPDeliverer - Message %I64d: ") _T("Message deleted. Action was taken by script subscribing to OnDeliveryStart."), pMessage->GetID()); LOG_APPLICATION(sMessage); PersistentMessage::DeleteObject(pMessage); return false; } } return true; }
void ReceiverChannel::Join(std::shared_ptr<SenderApplication> application, const OperationCompletedCallback& callback) { if (!callback) throw std::runtime_error("The join function requires a valid callback to be provided."); GetStatus([=](const ReceiverStatus& status) { if (!application) return callback(false); if (_application) return callback(false); auto it = std::find_if(status.applications.begin(), status.applications.end(), [=](const ReceiverStatus::ApplicationInfo& app_info) { return app_info.application_id == application->GetID(); }); if (it == status.applications.end()) return callback(false); _application = application; _application->Initialize(_connection.channel_factory, *it, callback); }); }
bool PersistentTCPIPPort::DeleteObject(std::shared_ptr<TCPIPPort> pObject) { SQLCommand command("delete from hm_tcpipports where portid = @PORTID"); command.AddParameter("@PORTID", pObject->GetID()); return Application::Instance()->GetDBManager()->Execute(command); }
void LoginState::processNewAccount(const std::string &input, std::shared_ptr<Connection> connection) { if(input == "y" or input == "Y") { Sender::Send("Enter password for the account\r\n", connection); m_state_map[connection->GetID()] = NEWPASSWORD; } else reset(connection); }
void LoginState::init(std::shared_ptr<Connection> connection) { GameState::init(connection); Sender::Send("Welcome to SkelMUD!\r\nPlease enter your username\r\n", connection); connection->SetPrompt(GetPrompt(connection)); int connection_id = connection->GetID(); if(m_state_map.find(connection_id) == m_state_map.end()) m_state_map[connection_id] = USERNAME; }
bool PersistentAlias::DeleteObject(std::shared_ptr<Alias> pAlias) { assert(pAlias->GetID()); bool bResult = false; if (pAlias->GetID() > 0) { SQLCommand command("delete from hm_aliases where aliasid = @ALIASID"); command.AddParameter("@ALIASID", pAlias->GetID()); bResult = Application::Instance()->GetDBManager()->Execute(command); Cache<Alias>::Instance()->RemoveObject(pAlias); } return bResult; }
bool PersistentRuleCriteria::DeleteObject(std::shared_ptr<RuleCriteria> pRuleCriteria) { SQLCommand command("delete from hm_rule_criterias where criteriaid = @CRITERIAID"); command.AddParameter("@CRITERIAID", pRuleCriteria->GetID()); bool bRet = Application::Instance()->GetDBManager()->Execute(command); return bRet; }
bool PersistentDistributionList::SaveObject(std::shared_ptr<DistributionList> pDistList, String &sErrorMessage, PersistenceMode mode) { if (!PreSaveLimitationsCheck::CheckLimitations(mode, pDistList, sErrorMessage)) return false; SQLStatement oStatement; oStatement.SetTable("hm_distributionlists"); oStatement.AddColumnInt64("distributionlistdomainid", pDistList->GetDomainID()); oStatement.AddColumn("distributionlistenabled", pDistList->GetActive() ? 1 : 0); oStatement.AddColumn("distributionlistaddress", pDistList->GetAddress()); oStatement.AddColumn("distributionlistrequireauth", pDistList->GetRequireAuth() ? 1 : 0); oStatement.AddColumn("distributionlistrequireaddress", pDistList->GetRequireAddress()); oStatement.AddColumn("distributionlistmode", pDistList->GetListMode()); if (pDistList->GetID() == 0) { oStatement.SetStatementType(SQLStatement::STInsert); oStatement.SetIdentityColumn("distributionlistid"); } else { oStatement.SetStatementType(SQLStatement::STUpdate); String sWhere; sWhere.Format(_T("distributionlistid = %I64d"), pDistList->GetID()); oStatement.SetWhereClause(sWhere); } bool bNewObject = pDistList->GetID() == 0; // Save and fetch ID __int64 iDBID = 0; bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0); if (bRetVal && bNewObject) pDistList->SetID((int) iDBID); Cache<DistributionList>::Instance()->RemoveObject(pDistList); return bRetVal; }
bool PersistentDistributionList::DeleteObject(std::shared_ptr<DistributionList> pDistList) { if (pDistList->GetID() == 0) { assert(0); return false; } DeleteMembers(pDistList); SQLCommand deleteCommand("delete from hm_distributionlists where distributionlistid = @LISTID"); deleteCommand.AddParameter("@LISTID", pDistList->GetID()); bool bResult = Application::Instance()->GetDBManager()->Execute(deleteCommand); Cache<DistributionList>::Instance()->RemoveObject(pDistList); return bResult; }
bool PersistentAlias::SaveObject(std::shared_ptr<Alias> pAlias, String &sErrorMessage, PersistenceMode mode) { if (!PreSaveLimitationsCheck::CheckLimitations(mode, pAlias, sErrorMessage)) return false; SQLStatement oStatement; oStatement.SetTable("hm_aliases"); oStatement.AddColumnInt64("aliasdomainid", pAlias->GetDomainID()); oStatement.AddColumn("aliasname", pAlias->GetName()); oStatement.AddColumn("aliasvalue", pAlias->GetValue()); oStatement.AddColumn("aliasactive", pAlias->GetIsActive()); if (pAlias->GetID() == 0) { oStatement.SetStatementType(SQLStatement::STInsert); oStatement.SetIdentityColumn("aliasid"); } else { oStatement.SetStatementType(SQLStatement::STUpdate); String sWhere; sWhere.Format(_T("aliasid = %I64d"), pAlias->GetID()); oStatement.SetWhereClause(sWhere); } bool bNewObject = pAlias->GetID() == 0; // Save and fetch ID __int64 iDBID = 0; bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0); if (bRetVal && bNewObject) pAlias->SetID((int) iDBID); Cache<Alias>::Instance()->RemoveObject(pAlias); return bRetVal; }
void LoginState::processNewPassword(const std::string &input, std::shared_ptr<Connection> connection) { Account account = connection->GetAccount(); int connection_id = connection->GetID(); //TODO: validate password account.SetUsername(connection->GetUsername()); account.SetPassword(input); game_data->AddAccount(account); game_data->SaveAccounts(GameData::ACCOUNT_FILE); Sender::Send("Account created\r\n", connection); connection->SetState(GameStates::CHARACTERCREATION, game_data); m_state_map.erase(connection_id); }
bool PersistentRuleCriteria::SaveObject(std::shared_ptr<RuleCriteria> pRuleCriteria) { SQLStatement oStatement; oStatement.SetTable("hm_rule_criterias"); bool bNewObject = pRuleCriteria->GetID() == 0; if (bNewObject) { oStatement.SetStatementType(SQLStatement::STInsert); oStatement.SetIdentityColumn("criteriaid"); } else { oStatement.SetStatementType(SQLStatement::STUpdate); String sWhere; sWhere.Format(_T("criteriaid = %I64d"), pRuleCriteria->GetID()); oStatement.SetWhereClause(sWhere); } oStatement.AddColumnInt64("criteriaruleid", pRuleCriteria->GetRuleID()); oStatement.AddColumn("criteriausepredefined", pRuleCriteria->GetUsePredefined()); oStatement.AddColumn("criteriapredefinedfield", pRuleCriteria->GetPredefinedField()); oStatement.AddColumn("criteriaheadername", pRuleCriteria->GetHeaderField()); oStatement.AddColumn("criteriamatchtype", pRuleCriteria->GetMatchType()); oStatement.AddColumn("criteriamatchvalue", pRuleCriteria->GetMatchValue()); // Save and fetch ID __int64 iDBID = 0; bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0); if (bRetVal && bNewObject) pRuleCriteria->SetID((int) iDBID); return bRetVal; }
bool PersistentAccount::DisableVacationMessage(std::shared_ptr<const Account> pAccount) { if (!pAccount) return false; String sCurrentTime = Time::GetCurrentDateTime(); SQLCommand command("update hm_accounts set accountvacationmessageon = 0 where accountid = @ACCOUNTID"); command.AddParameter("@ACCOUNTID", pAccount->GetID()); return Application::Instance()->GetDBManager()->Execute(command); }
void Server::Leave(std::shared_ptr<ClientConnection> client) { eid leaving_client_id = client->GetID(); client->DoLeave(); // Send out entity destroyed events and client leave messages. LockClientList(); this->clients.erase(client); UnlockClientList(); // Notify other clients that a client left. for (auto client : this->clients) { client->OnClientLeave(leaving_client_id); } }
bool PreSaveLimitationsCheck::CheckLimitations(PersistenceMode mode, std::shared_ptr<DistributionList> list, String &resultDescription) { if (mode == PersistenceModeRestore) return true; std::shared_ptr<Domain> domain = GetDomain(list->GetDomainID()); if (GetDuplicateExist(domain, TypeList,list->GetID(), list->GetAddress())) return DuplicateError(resultDescription); if (list->GetID() == 0) { if (domain->GetMaxNoOfDistributionLists() && domain->GetDistributionLists()->GetCount() >= domain->GetMaxNoOfDistributionLists()) { resultDescription = "The maximum number of distribution lists have been created."; return false; } } return true; }
bool PersistentAccount::UpdateLastLogonTime(std::shared_ptr<const Account> pAccount) { if (!pAccount) return false; AnsiString sCurrentTime = Time::GetCurrentDateTime(); SQLCommand command("update hm_accounts set accountlastlogontime = @LASTLOGONTIME where accountid = @ACCOUNTID"); command.AddParameter("@LASTLOGONTIME", sCurrentTime); command.AddParameter("@ACCOUNTID", pAccount->GetID()); return Application::Instance()->GetDBManager()->Execute(command); }
bool PreSaveLimitationsCheck::CheckLimitations(PersistenceMode mode, std::shared_ptr<Alias> alias, String &resultDescription) { if (mode == PersistenceModeRestore) return true; std::shared_ptr<Domain> domain = GetDomain(alias->GetDomainID()); if (GetDuplicateExist(domain, TypeAlias, alias->GetID(), alias->GetName())) return DuplicateError(resultDescription); if (alias->GetID() == 0) { if (domain->GetMaxNoOfAliasesEnabled() && domain->GetAliases()->GetCount() >= domain->GetMaxNoOfAliases()) { resultDescription = "The maximum number of aliases have been created."; return false; } } return true; }