public static void ClientReadyHandler(ZoneClient client, Packet packet) { if (client.Admin > 0) { client.Character.DropMessage("AdminLevel = {0}; ClientLoad = {1};", client.Admin, ClientManager.Instance.ZoneLoad); } Handler4.SendUsablePoints(client); if (!client.Character.IsDead) { // Just logged on. client.Character.Map.FinalizeAdd(client.Character); } else { // Reviving, not readding for this one! MapInfo mi; if (DataProvider.Instance.MapsByID.TryGetValue(client.Character.MapID, out mi)) { client.Character.State = PlayerState.Normal; client.Character.Map.SendCharacterLeftMap(client.Character, false); client.Character.Position.X = mi.RegenX; client.Character.Position.Y = mi.RegenY; client.Character.Map.SendCharacterEnteredMap(client.Character); } client.Character.SetHP(client.Character.MaxHP / 4); } }
public static void TransferKeyHandler(ZoneClient client, Packet packet) { ushort randomID; string characterName, checksums; //TODO: check in securityclient if (!packet.TryReadUShort(out randomID) || !packet.TryReadString(out characterName, 16) || !packet.TryReadString(out checksums, 832)) { Log.WriteLine(LogLevel.Warn, "Invalid game transfer."); return; } var transfer = ClientManager.Instance.GetTransfer(characterName); if (transfer == null || transfer.HostIP != client.Host || transfer.RandID != randomID) { Log.WriteLine(LogLevel.Warn, "{0} tried to login without a valid client transfer.", client.Host); //Handler3.SendError(client, ServerError.INVALID_CREDENTIALS); Handler4.SendConnectError(client, ConnectErrors.RequestedCharacterIDNotMatching); return; } try { ClientManager.Instance.RemoveTransfer(characterName); var zonecharacter = new ZoneCharacter(transfer.CharID); if (zonecharacter.Character.AccountID != transfer.AccountID) { Log.WriteLine(LogLevel.Warn, "Character is logging in with wrong account ID."); Handler4.SendConnectError(client, ConnectErrors.RequestedCharacterIDNotMatching); //Handler3.SendError(client, ServerError.INVALID_CREDENTIALS); return; } client.Authenticated = true; client.Admin = transfer.Admin; client.AccountID = transfer.AccountID; client.Username = transfer.Username; client.Character = zonecharacter; zonecharacter.Client = client; //Zonecharacter.Client. = ; if (ClientManager.Instance.AddClient(client)) { zonecharacter.SendGetIngameChunk(); //TODO: interserver packet? Log.WriteLine(LogLevel.Debug, "{0} logged in successfully!", zonecharacter.Name); } } catch (Exception ex) { Log.WriteLine(LogLevel.Exception, "Error loading character {0}: {1} - {2}", characterName, ex.ToString(), ex.StackTrace); Handler4.SendConnectError(client, ConnectErrors.ErrorInCharacterInfo); } }