private static void AccountSelectCallback(MySqlResult result, Session session) { var connectResponse = new ServerPacket(0x0B, PacketHeaderFlags.ConnectRequest); connectResponse.Payload.Write(0u); connectResponse.Payload.Write(0u); connectResponse.Payload.Write(13626398284849559039ul); // some sort of check value? connectResponse.Payload.Write((ushort)0); connectResponse.Payload.Write((ushort)0); connectResponse.Payload.Write(ISAAC.ServerSeed); connectResponse.Payload.Write(ISAAC.ClientSeed); connectResponse.Payload.Write(0u); NetworkManager.SendPacket(ConnectionType.Login, connectResponse, session); if (result.Count == 0) { session.SendCharacterError(CharacterError.AccountDoesntExist); return; } uint accountId = result.Read <uint>(0, "id"); string account = result.Read <string>(0, "account"); if (WorldManager.Find(account) != null) { session.SendCharacterError(CharacterError.AccountInUse); return; } string digest = SHA2.Hash(SHA2Type.SHA256, result.Read <string>(0, "password") + result.Read <string>(0, "salt")); /*if (glsTicket != digest) * { * }*/ /*if (WorldManager.ServerIsFull()) * { * session.SendCharacterError(CharacterError.LogonServerFull); * return; * }*/ // TODO: check for account bans session.SetAccount(accountId, account); }
public IEnumerable <(byte CityStateId, WorldPosition Position)> GetCharacterSpawns() { MySqlResult result = SelectPreparedStatement(WorldPreparedStatement.CharacterSpawnSelect); for (uint i = 0; i < result?.Count; i++) { yield return(result.Read <byte>(i, "cityStateId"), new WorldPosition(result.Rows[(int)i])); } }
public static void CharacterListSelectCallback(MySqlResult result, Session session) { var characterList = new ServerPacket(0x0B, PacketHeaderFlags.EncryptedChecksum); var characterFragment = new ServerPacketFragment(9, FragmentOpcode.CharacterList); characterFragment.Payload.Write(0u); characterFragment.Payload.Write(result.Count); session.CachedCharacters.Clear(); for (byte i = 0; i < result.Count; i++) { uint lowGuid = result.Read <uint>(i, "guid"); string name = result.Read <string>(i, "name"); characterFragment.Payload.Write(lowGuid); characterFragment.Payload.WriteString16L(name); ulong deleteTime = result.Read <ulong>(i, "deleteTime"); characterFragment.Payload.Write(deleteTime != 0ul ? (uint)(WorldManager.GetUnixTime() - deleteTime) : 0u); session.CachedCharacters.Add(new CachedCharacter(lowGuid, i, name)); } characterFragment.Payload.Write(0u); characterFragment.Payload.Write(11u /*slotCount*/); characterFragment.Payload.WriteString16L(session.Account); characterFragment.Payload.Write(0u /*useTurbineChat*/); characterFragment.Payload.Write(0u /*hasThroneOfDestiny*/); characterList.Fragments.Add(characterFragment); NetworkManager.SendPacket(ConnectionType.Login, characterList, session); var serverName = new ServerPacket(0x0B, PacketHeaderFlags.EncryptedChecksum); var serverNameFragment = new ServerPacketFragment(9, FragmentOpcode.ServerName); serverNameFragment.Payload.Write(0u); serverNameFragment.Payload.Write(0u); serverNameFragment.Payload.WriteString16L(ConfigManager.Config.Server.WorldName); serverName.Fragments.Add(serverNameFragment); NetworkManager.SendPacket(ConnectionType.Login, serverName, session); }
public async Task <uint> GetAccount(string sessionId) { if (sessionId == string.Empty) { return(0u); } MySqlResult result = await SelectPreparedStatementAsync(AuthenticationPreparedStatement.AccountSelect, sessionId); return(result.Count != 0u ? result.Read <uint>(0, "id") : 0u); }
public ulong GetMaxCharacterId() { MySqlResult result = SelectPreparedStatement(DataCentrePreparedStatement.CharacterMaxSelect); return(result?.Read <ulong>(0, "max") ?? 0ul); }
public async Task <(uint ServiceAccountId, ulong CharacterId)> GetCharacterSession(uint actorId, string source) { MySqlResult result = await SelectPreparedStatementAsync(DataCentrePreparedStatement.CharacterSessionSelect, actorId, source); return(result?.Count > 0u ? (result.Read <uint>(0, "serviceAccountId"), result.Read <ulong>(0, "id")) : (0u, 0ul)); }
public async Task <bool> IsCharacterNameAvailable(string name) { MySqlResult result = await SelectPreparedStatementAsync(DataCentrePreparedStatement.CharacterNameCount, name); return(result?.Read <uint>(0, "count") == 0u); }