/* * Ascent MMORPG Server * Copyright (C) 2005-2007 Ascent Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef LOGONCOMMHANDLER_H #define LOGONCOMMHANDLER_H typedef struct { uint32 ID; string Name; string Address; uint32 Port; uint32 ServerID; uint32 RetryTime; bool Registered; }LogonServer; typedef struct { string Name; string Address; uint32 Colour; uint32 Icon; uint32 TimeZone; float Population; }Realm; enum RealmType { REALMTYPE_NORMAL = 0, REALMTYPE_PVP = 4, REALMTYPE_RP = 6, REALMTYPE_RPPVP = 8, }; class SocketLoadBalancer; class LogonCommHandler : public Singleton { map logons; map pending_logons; set realms; set servers; uint32 idhigh; uint32 next_request; Mutex mapLock; Mutex pendingLock; bool pings; uint32 _realmType; public: uint8 sql_passhash[20]; LogonCommHandler(); ~LogonCommHandler(); LogonCommClientSocket * ConnectToLogon(string Address, uint32 Port); void UpdateAccountCount(uint32 account_id, uint8 add); void RequestAddition(LogonCommClientSocket * Socket); void CheckAllServers(); void Startup(); void ConnectionDropped(uint32 ID); void AdditionAck(uint32 ID, uint32 ServID); void UpdateSockets(); void Connect(LogonServer * server); void LogonDatabaseSQLExecute(const char* str, ...); void LogonDatabaseReloadAccounts(); void LoadRealmConfiguration(); void AddServer(string Name, string Address, uint32 Port); inline uint32 GetRealmType() { return _realmType; } void SetRealmType(uint32 type) { _realmType = type; } ///////////////////////////// // Worldsocket stuff /////// uint32 ClientConnected(string AccountName, WorldSocket * Socket); void UnauthedSocketClose(uint32 id); void RemoveUnauthedSocket(uint32 id); inline WorldSocket* GetSocketByRequest(uint32 id) { //pendingLock.Acquire(); WorldSocket * sock; map::iterator itr = pending_logons.find(id); sock = (itr == pending_logons.end()) ? 0 : itr->second; //pendingLock.Release(); return sock; } inline Mutex & GetPendingLock() { return pendingLock; } }; #define sLogonCommHandler LogonCommHandler::getSingleton() #endif