#ifndef LOGINSERV_H_ #define LOGINSERV_H_ #include "../../src/GWServer.h" #include "../../src/Log.h" #include "../../src/GWLPDatabase.h" #include "../../src/hnl/nl.h" #include "../../src/IdGenerator.h" #include #define SERVER_VERSION "0.0.1" #define GetClientData() ClientData* pMyClient=gLoginServer.AccessClient(pClient->externalId) #define ServerOpcode(name) gLoginServer.mServerOpcodesTable[name] #define logFile gLoginServer.mSysLog struct ClientData { //Core data ushort myId; NLsocket socketId; ulong verifCode; ulong accountId; ulong accessLevel; //Used for playing a character wchar_t characterName[30]; ushort zoneId; ulong characterId; uchar compHash[32]; ushort gameServerId; ulong missionId; //Used for client authentication ulong transferId1; ulong transferId2; ulong ownedCampaigns; uchar ownsEotn; //Used for account creation char* pAccessKey; wchar_t* pEmailAddr; //Flags bool encryptedConnectionEstablished; bool loadIntoInstance; bool keyValidated; bool authenticated; bool updateConnection; bool dispatched; //Stuff for use with queries int (*QueryProcess)(QUERY_RESULT *result, ClientData* lir); unsigned long queryId; void* pTempData; ~ClientData() { if(pEmailAddr!=NULL) { delete [] pEmailAddr; } if(pAccessKey!=NULL) { delete [] pAccessKey; } } }; //Copypasta struct mycomp { // define hash function for strings enum { // parameters for hash table bucket_size = 4, // 0 < bucket_size min_buckets = 8}; // min_buckets = 2 ^^ N, 0 < N size_t operator()(const char *s1) const { // hash string s1 to size_t value const unsigned char *p = (const unsigned char *)s1; size_t hashval = 0; while (*p != '\0') hashval += *p++; // or whatever return (hashval); } bool operator()(const char *s1, const char *s2) const { // test if s1 ordered before s2 return (strcmp(s1, s2) < 0); } }; class LoginServ { public: int Init(); int Update(); ~LoginServ(); ClientData* AccessClient(ushort id); GwServer* mpLoginServer; GwServer* mpInternalServer; GWLPDatabase mDatabase; IdGenerator mClientIds; STDEXT::hash_map mClients; STDEXT::hash_map mServerOpcodesTable; Log mSysLog; //Server configuration bool mServerLocked; bool mThrottleCpu; bool mRequireValidAccessKey; char mAuthPassword[25]; int mMaxGameServers; bool mDetectGameServIp; bool mIgnoreNoGameServer; bool mRequireValidPassword; //Neutered File server uchar* mpNoUpdatePacket; //Default interface layout data ulong mDefaultInterfaceSize; uchar* mpDefaultInterface; }; extern LoginServ gLoginServer; #endif