Ejemplo n.º 1
0
 public void HandleClientShutdown(BattleNetClient client)
 {
     m_client.UnregisterChannelDidNotExistNotification(Priority.Low, __ChannelDidNotExist);
     m_client.UnregisterChannelListReceivedNotification(Priority.Low, __ChannelListReceived);
     m_client.UnregisterChannelWasFullNotification(Priority.Low, __ChannelWasFull);
     m_client.UnregisterChannelWasRestrictedNotification(Priority.Low, __ChannelWasRestricted);
     m_client.UnregisterClientCheckFailedNotification(Priority.Low, __ClientCheckFailed);
     m_client.UnregisterClientCheckPassedNotification(Priority.Low, __ClientCheckPassed);
     m_client.UnregisterCommandSentNotification(Priority.Low, __CommandSent);
     m_client.UnregisterConnectedNotification(Priority.Low, __Connected);
     m_client.UnregisterDisconnectedNotification(Priority.Low, __Disconnected);
     m_client.UnregisterEnteredChatNotification(Priority.Low, __EnteredChat);
     m_client.UnregisterErrorNotification(Priority.Low, __Error);
     m_client.UnregisterInformationNotification(Priority.Low, __Information);
     m_client.UnregisterInformationReceivedNotification(Priority.Low, __InformationReceived);
     m_client.UnregisterJoinedChannelNotification(Priority.Low, __JoinedChannel);
     m_client.UnregisterLoginFailedNotification(Priority.Low, __LoginFailed);
     m_client.UnregisterLoginSucceededNotification(Priority.Low, __LoginSucceeded);
     m_client.RegisterMessageSentNotification(Priority.Low, __MessageSent);
     m_client.RegisterServerBroadcastNotification(Priority.Low, __ServerBroadcast);
     m_client.RegisterServerErrorReceivedNotification(Priority.Low, __ServerErrorReceived);
     m_client.RegisterUserEmotedNotification(Priority.Low, __UserEmoted);
     m_client.RegisterUserFlagsChangedNotification(Priority.Low, __UserFlagsChanged);
     m_client.RegisterUserJoinedNotification(Priority.Low, __UserJoined);
     m_client.RegisterUserLeftNotification(Priority.Low, __UserLeft);
     m_client.RegisterUserShownNotification(Priority.Low, __UserShown);
     m_client.RegisterUserSpokeNotification(Priority.Low, __UserSpoke);
     m_client.RegisterWardentUnhandledNotification(Priority.Low, __WardenUnhandled);
     m_client.RegisterWhisperReceivedNotification(Priority.Low, __WhisperReceived);
     m_client.RegisterWhisperSentNotification(Priority.Low, __WhisperSent);
 }
        public static Point GetClosestEnemyPosition(BattleNetClient client, out List <Movement> movements, int maxTurnsToCalculate)
        {
            var enemyPosition = PointUtility.CreateNegativePoint();

            movements = new List <Movement>();

            List <List <Point> >    checkedPoints      = new List <List <Point> >(new [] { new List <Point>(new [] { client.GetPlayerTank() }) });
            List <List <Movement> > movementsInProcess = new List <List <Movement> >(new [] { new List <Movement>(new [] { Movement.Stop }) });
            List <Point>            currentRangePoints = new List <Point>(new[] { client.GetPlayerTank() });

            for (int count = 0; count < maxTurnsToCalculate && enemyPosition.IsNegativePoint(); count++)
            {
                enemyPosition = GetClosestEnemyPosition(client,
                                                        checkedPoints, movementsInProcess,
                                                        currentRangePoints,
                                                        out movements);
            }

            if (movements.Any())
            {
                movements.RemoveAt(0);
                return(enemyPosition);
            }
            else
            {
                return(PointUtility.CreateNegativePoint());
            }
        }
Ejemplo n.º 3
0
        public MoveProgram(BattleNetClient client)
        {
            _client   = client;
            _moveType = MoveType.Undefined;

            _randomValueGenerator = new Random();
        }
Ejemplo n.º 4
0
 private void Awake()
 {
     s_instance = this;
     OverlayUI.Get().AddGameObject(base.gameObject, CanvasAnchor.CENTER, false, CanvasScaleMode.HEIGHT);
     this.m_logo = AssetLoader.Get().LoadGameObject(FileUtils.GameAssetPathToName(this.m_logoPrefab), true, false);
     GameUtils.SetParent(this.m_logo, this.m_logoContainer, true);
     this.m_logo.SetActive(false);
     this.m_webLoginCanvas = null;
     this.Show();
     this.UpdateLayout();
     if (Vars.Key("Aurora.ClientCheck").GetBool(true) && BattleNetClient.needsToRun)
     {
         BattleNetClient.quitHearthstoneAndRun();
     }
     else
     {
         Network.Get().RegisterQueueInfoHandler(new Network.QueueInfoHandler(this.QueueInfoHandler));
         if (DemoMgr.Get().GetMode() == DemoMode.APPLE_STORE)
         {
             this.m_demoDisclaimer.SetActive(true);
         }
         if (ApplicationMgr.IsInternal() && (ApplicationMgr.AllowResetFromFatalError != null))
         {
             this.m_devClearLoginButton.gameObject.SetActive(true);
             this.m_devClearLoginButton.AddEventListener(UIEventType.RELEASE, new UIEvent.Handler(this.ClearLogin));
         }
     }
 }
Ejemplo n.º 5
0
        // Methods
        public EnterChatResponse(byte[] data) : base(data)
        {
            this.clientVersion  = -1;
            this.characterType  = BattleNetCharacter.Unknown;
            this.characterLevel = -1;
            this.characterAct   = -1;
            this.characterTitle = CharacterTitle.None;
            this.username       = ByteConverter.GetNullString(data, 3);
            int startIndex = 4 + this.username.Length;

            this.client = (BattleNetClient)BitConverter.ToUInt32(data, startIndex);
            if (data[startIndex += 4] == 0)
            {
                this.account = ByteConverter.GetNullString(data, startIndex + 1);
            }
            else
            {
                this.realm  = ByteConverter.GetString(data, startIndex, -1, 0x2c);
                startIndex += 1 + this.realm.Length;
                this.name   = ByteConverter.GetString(data, startIndex, -1, 0x2c);
                startIndex += 1 + this.name.Length;
                int num2 = ByteConverter.GetByteOffset(data, 0, startIndex);
                this.account = ByteConverter.GetNullString(data, (startIndex + num2) + 1);
                if (this.client == BattleNetClient.Diablo2LoD)
                {
                    this.characterFlags |= CharacterFlags.Expansion;
                }
                StatString.ParseD2StatString(data, startIndex, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
            }
        }
Ejemplo n.º 6
0
 void RegisterBattleNetClient(BattleNetClient battleNetClient)
 {
     m_battleNetClient               = battleNetClient;
     m_battleNetClient.onGameStart  += OnGameStart;
     m_battleNetClient.onGameUpdate += OnGameUpdate;
     m_battleNetClient.onGameEnd    += OnGameEnd;
 }
Ejemplo n.º 7
0
 void UnRegisterBattleNetClient(BattleNetClient battleNetClient)
 {
     m_battleNetClient.onGameStart  -= OnGameStart;
     m_battleNetClient.onGameUpdate -= OnGameUpdate;
     m_battleNetClient.onGameEnd    -= OnGameEnd;
     m_battleNetClient = null;
 }
Ejemplo n.º 8
0
        private void client_Disconnected(object sender, EventArgs e)
        {
            BattleNetClient client = sender as BattleNetClient;

            if (client == null)
            {
                return;
            }
            ProfileDocument profileDoc = this.dock.ActiveDocument as ProfileDocument;

            if (profileDoc == null)
            {
                return;
            }
            if (profileDoc.Client == client)
            {
                SyncDel go = delegate
                {
                    this.connectToolStripMenuItem1.Enabled   = true;
                    this.disconnectToolStripMenuItem.Enabled = false;
                };
                if (InvokeRequired)
                {
                    BeginInvoke(go);
                }
                else
                {
                    go();
                }
            }
        }
Ejemplo n.º 9
0
 // Methods
 public NotifyJoin(byte[] data) : base(data)
 {
     this.client   = (BattleNetClient)BitConverter.ToUInt32(data, 3);
     this.version  = BitConverter.ToUInt32(data, 7);
     this.name     = ByteConverter.GetNullString(data, 11);
     this.password = ByteConverter.GetNullString(data, 12 + this.name.Length);
 }
Ejemplo n.º 10
0
        public NewsList(BattleNetClient client)
            : this()
        {
            m_client = client;

            m_client.ServerNews += new BNSharp.BattleNet.ServerNewsEventHandler(m_client_ServerNews);
        }
Ejemplo n.º 11
0
 // Methods
 public AdInfoRequest(byte[] data) : base(data)
 {
     this.platform  = (BattleNetPlatform)BitConverter.ToUInt32(data, 3);
     this.client    = (BattleNetClient)BitConverter.ToUInt32(data, 7);
     this.id        = BitConverter.ToUInt32(data, 11);
     this.timestamp = TimeUtils.ParseUnixTimeUtc(BitConverter.ToUInt32(data, 15));
 }
 public void UnregisterPackets(BattleNetClient client)
 {
     if (m_registered)
     {
         m_conn.UnregisterPackets(client);
         m_registered = false;
     }
 }
Ejemplo n.º 13
0
 // Methods
 public AdInfoRequest(byte[] data)
     : base(data)
 {
     this.platform = (BattleNetPlatform) BitConverter.ToUInt32(data, 3);
     this.client = (BattleNetClient) BitConverter.ToUInt32(data, 7);
     this.id = BitConverter.ToUInt32(data, 11);
     this.timestamp = TimeUtils.ParseUnixTimeUtc(BitConverter.ToUInt32(data, 15));
 }
        private static Point GetClosestEnemyPosition(BattleNetClient client, List <List <Point> > checkedPoints,
                                                     List <List <Movement> > movements, List <Point> currentRangePoints, out List <Movement> road)
        {
            if (client.IsAnyOfEnemyAt(currentRangePoints))
            {
                for (int index = 0; index < currentRangePoints.Count; index++)
                {
                    if (client.IsEnemyAt(currentRangePoints[index]))
                    {
                        road = new List <Movement>(movements[index]);
                        return(currentRangePoints[index]);
                    }
                }
            }

            var iterationMap      = MapUtility.IterationMap;
            var nextRangePoints   = new List <Point>();
            var nextMovements     = new List <List <Movement> >();
            var nextCheckedPoints = new List <List <Point> >();

            for (int index = 0; index < movements.Count; index++)
            {
                foreach (var iteration in iterationMap)
                {
                    var nextPosition = iteration.Value(currentRangePoints[index]);
                    var movement     = iteration.Key.ToMovement();

                    if (checkedPoints[index].Exists(x => x.X == nextPosition.X && x.Y == nextPosition.Y))
                    {
                        continue;
                    }

                    if (client.IsOutOf(nextPosition) || client.IsObstacleAt(nextPosition))
                    {
                        continue;
                    }

                    nextRangePoints.Add(nextPosition);

                    var move = new List <Movement>(movements[index]);
                    move.Add(iteration.Key.ToMovement());
                    nextMovements.Add(move);

                    var nextChecked = new List <Point>(checkedPoints[index]);
                    nextChecked.Add(currentRangePoints[index]);
                    nextCheckedPoints.Add(nextChecked);
                }
            }

            checkedPoints.Clear();
            checkedPoints.AddRange(nextCheckedPoints);
            movements.Clear();
            movements.AddRange(nextMovements);
            currentRangePoints.Clear();
            currentRangePoints.AddRange(nextRangePoints);
            road = new List <Movement>();
            return(PointUtility.CreateNegativePoint());
        }
Ejemplo n.º 15
0
        public ChannelList(BattleNetClient client)
            : this()
        {
            m_client = client;

            ProcessEventSetup();

            m_resourceProvider = ProfileResourceProvider.GetForClient(client);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new <see>ChatDocument</see> to handle the specified client.
        /// </summary>
        /// <param name="client">The client to handle.</param>
        public ChatDocument(BattleNetClient client)
            : this()
        {
            m_client  = client;
            m_prp     = ProfileResourceProvider.GetForClient(client);
            m_profile = client.Settings as ClientProfile;

            SetupEventRegistration();
        }
Ejemplo n.º 17
0
 public static WarcraftClient CreateWarcraftClient(string apiKey)
 {
     var options = new BattleNetClientOptions()
     {
         ApiKey = apiKey
     };
     var client = new BattleNetClient(options);
     return new WarcraftClient(client);
 }
        private static List <Movement> GetRoad(BattleNetClient client, Point targetPoint, List <List <Point> > checkedPoints,
                                               List <List <Movement> > movements, List <Point> currentRangePoints)
        {
            if (currentRangePoints.Exists(x => x.X == targetPoint.X && x.Y == targetPoint.Y))
            {
                for (int index = 0; index < currentRangePoints.Count; index++)
                {
                    if (currentRangePoints[index].X == targetPoint.X && currentRangePoints[index].Y == targetPoint.Y)
                    {
                        return(movements[index]);
                    }
                }
            }

            var iterationMap      = MapUtility.IterationMap;
            var nextRangePoints   = new List <Point>();
            var nextMovements     = new List <List <Movement> >();
            var nextCheckedPoints = new List <List <Point> >();

            for (int index = 0; index < movements.Count; index++)
            {
                foreach (var iteration in iterationMap)
                {
                    var nextPosition = iteration.Value(currentRangePoints[index]);
                    var movement     = iteration.Key.ToMovement();

                    if (checkedPoints[index].Exists(x => x.X == nextPosition.X && x.Y == nextPosition.Y))
                    {
                        continue;
                    }

                    if (client.IsOutOf(nextPosition) || client.IsObstacleAt(nextPosition))
                    {
                        continue;
                    }

                    nextRangePoints.Add(nextPosition);

                    var move = new List <Movement>(movements[index]);
                    move.Add(iteration.Key.ToMovement());
                    nextMovements.Add(move);

                    var nextChecked = new List <Point>(checkedPoints[index]);
                    nextChecked.Add(currentRangePoints[index]);
                    nextCheckedPoints.Add(nextChecked);
                }
            }

            checkedPoints.Clear();
            checkedPoints.AddRange(nextCheckedPoints);
            movements.Clear();
            movements.AddRange(nextMovements);
            currentRangePoints.Clear();
            currentRangePoints.AddRange(nextRangePoints);

            return(new List <Movement>());
        }
Ejemplo n.º 19
0
 public FriendsList(BattleNetClient client)
     : this()
 {
     client.FriendListReceived += new FriendListReceivedEventHandler(client_FriendListReceived);
     client.FriendMoved        += new FriendMovedEventHandler(client_FriendMoved);
     client.FriendAdded        += new FriendAddedEventHandler(client_FriendAdded);
     client.FriendRemoved      += new FriendRemovedEventHandler(client_FriendRemoved);
     client.FriendUpdated      += new FriendUpdatedEventHandler(client_FriendUpdated);
 }
Ejemplo n.º 20
0
        public async Task SetupAsync()
        {
            var diabloApi           = DiabloApiFactory.CreateApi();
            var authenticationScope = await diabloApi.CreateAuthenticationScopeAsync();

            var regionString       = EnumConversionHelper.RegionToString(authenticationScope.Region);
            var localizationString = EnumConversionHelper.LocalizationToString(authenticationScope.Localization);

            Client = new BattleNetClient(authenticationScope.AccessToken, regionString, localizationString, new DefaultTokenBucket());
        }
        public void RegisterPackets(BattleNetClient client)
        {
            Product clientProduct = Product.GetByProductCode(client.Settings.Client);

            if (object.ReferenceEquals(clientProduct, Product.Diablo2Retail) || object.ReferenceEquals(clientProduct, Product.Diablo2Expansion))
            {
                m_registered = true;
                m_conn.RegisterPackets(client);
            }
        }
Ejemplo n.º 22
0
        public ClanList(BattleNetClient client)
            : this()
        {
            m_client = client;

            m_prp = ProfileResourceProvider.GetForClient(client);

            client.ClanMemberListReceived += new ClanMemberListEventHandler(client_ClanMemberListReceived);
            client.ClanMembershipReceived += new ClanMembershipEventHandler(client_ClanMembershipReceived);
        }
Ejemplo n.º 23
0
        private ProfileDocument(BattleNetClient client)
            : this()
        {
            m_client  = client;
            this.Text = this.TabText = (client.Settings as ClientProfile).ProfileName;

            if (client.Settings.Client == Product.StarcraftRetail.ProductCode || client.Settings.Client == Product.StarcraftBroodWar.ProductCode ||
                client.Settings.Client == Product.Warcraft3Retail.ProductCode || client.Settings.Client == Product.Warcraft3Expansion.ProductCode)
            {
                //WardenPacketHandler module = new WardenPacketHandler(client);
                //m_client.WardenHandler = module;
            }

            client.EventExceptionThrown += new EventExceptionEventHandler(client_EventExceptionThrown);

            m_chat      = new ChatDocument(client);
            m_chat.Text = "Main chat window (Disconnected)";
            m_chat.Show(this.dock);

            m_channel = new ChannelList(client);
            m_channel.Show(this.dock);

            IBattleNetSettings settings   = client.Settings;
            string             clientCode = settings.Client;

            if (clientCode.Equals(Product.Warcraft3Retail.ProductCode, StringComparison.Ordinal) ||
                clientCode.Equals(Product.Warcraft3Expansion.ProductCode, StringComparison.Ordinal))
            {
                m_friends = new FriendsList(client);
                m_friends.Show(this.dock);

                m_clan = new ClanList(client);
                m_clan.Show(this.dock);

                m_news = new NewsList(client);
                m_news.Show(this.dock);
                m_news.DockState = DockState.DockLeftAutoHide;
            }
            else if (clientCode.Equals(Product.StarcraftRetail.ProductCode, StringComparison.Ordinal) ||
                     clientCode.Equals(Product.StarcraftBroodWar.ProductCode, StringComparison.Ordinal))
            {
                m_friends = new FriendsList(client);
                m_friends.Show(this.dock);
            }

            m_channel.Show();

            m_ssUri = m_chat.StylesheetUri;

            m_documents.Add(m_chat);

            client.RegisterWarcraftProfileReceivedNotification(Priority.Low, WarcraftProfileReceived);

            m_channel.VoidView = this.VoidView;
        }
Ejemplo n.º 24
0
        private static void Move(BattleNetClient gcb)
        {
            var r    = new Random();
            var done = false;

            switch (r.Next(5))
            {
            case 0:
                if (!gcb.IsBarrierAt(gcb.PlayerX, gcb.PlayerY - 1))
                {
                    gcb.SendActions(gcb.Up());
                    Console.WriteLine($"Move up");
                    done = true;
                }
                break;

            case 1:
                if (!gcb.IsBarrierAt(gcb.PlayerX + 1, gcb.PlayerY))
                {
                    gcb.SendActions(gcb.Right());
                    Console.WriteLine($"Move right");
                    done = true;
                }
                break;

            case 2:
                if (!gcb.IsBarrierAt(gcb.PlayerX, gcb.PlayerY + 1))
                {
                    gcb.SendActions(gcb.Down());
                    Console.WriteLine($"Move down");
                    done = true;
                }
                break;

            case 3:
                if (!gcb.IsBarrierAt(gcb.PlayerX - 1, gcb.PlayerY))
                {
                    gcb.SendActions(gcb.Left());
                    Console.WriteLine($"Move left");
                    done = true;
                }
                break;

            case 4:
                gcb.SendActions(gcb.Act());
                Console.WriteLine($"act");
                done = true;
                break;
            }
            if (done == false)
            {
                gcb.SendActions(gcb.Blank());
            }
        }
Ejemplo n.º 25
0
        public ProfilePluginManager(ClientProfile profile, BattleNetClient client, ProfileDocument view)
        {
            m_profile = profile;
            m_client  = client;
            m_view    = view;

            m_clientPlugins        = new List <ISingleClientPlugin>();
            m_multiClientPlugins   = new List <IMultiClientPlugin>();
            m_clientPluginSettings = new Dictionary <ISingleClientPlugin, Dictionary <string, string> >();

            EnumeratePlugins(profile.PluginSettings);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Registers a provider for the specified connection and returns the provider.
        /// </summary>
        /// <param name="client">The client connection to register.</param>
        /// <returns>A <see>ProfileResourceProvider</see> if the profile was newly registered; or <see langword="null" /> if the profile
        /// was already registered.</returns>
        public static ProfileResourceProvider RegisterProvider(BattleNetClient client)
        {
            ProfileResourceProvider provider = null;

            if (!s_providers.ContainsKey(client))
            {
                provider = new ProfileResourceProvider(client);
                s_providers.Add(client, provider);
            }

            return(provider);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Unregisters a profile and cleans up its resources.
        /// </summary>
        /// <param name="client">The client to unregister.</param>
        public static void UnregisterProvider(BattleNetClient client)
        {
            if (!s_providers.ContainsKey(client))
            {
                return;
            }

            ProfileResourceProvider provider = s_providers[client];

            s_providers.Remove(client);

            provider.Dispose();
        }
        public CommandsProcessor(BattleNetClient client)
        {
            _client = client;

            _movementMap = new Dictionary <Movement, string>
            {
                { Movement.Down, _client.Down() },
                { Movement.Up, _client.Up() },
                { Movement.Left, _client.Left() },
                { Movement.Right, _client.Right() },
                { Movement.Stop, _client.Blank() },
            };
        }
Ejemplo n.º 29
0
        private static void LoginWithNewCredentials(object sender)
        {
            console.OutputForegroundColor = ConsoleColor.Cyan;
            console.WriteLine("Please enter new credentials.");
            console.OutputForegroundColor = ConsoleColor.Gray;
            console.Write("Username: "******"Password: ");
            _settings.Password = Console.ReadLine();

            BattleNetClient client = sender as BattleNetClient;

            client.ContinueLogin();
        }
Ejemplo n.º 30
0
 // Methods
 public BnetConnectionRequest(byte[] data) : base(data)
 {
     this.protocol            = BitConverter.ToUInt32(data, 3);
     this.platform            = (BattleNetPlatform)BitConverter.ToUInt32(data, 7);
     this.client              = (BattleNetClient)BitConverter.ToUInt32(data, 11);
     this.version             = BitConverter.ToUInt32(data, 15);
     this.language            = BitConverter.ToUInt32(data, 0x13);
     this.localIP             = new System.Net.IPAddress((long)BitConverter.ToUInt32(data, 0x17));
     this.timeZoneBias        = BitConverter.ToUInt32(data, 0x1b);
     this.localeID            = BitConverter.ToUInt32(data, 0x1f);
     this.languageID          = BitConverter.ToUInt32(data, 0x23);
     this.countryAbbreviation = ByteConverter.GetNullString(data, 0x27);
     this.countryName         = ByteConverter.GetNullString(data, 40 + this.countryAbbreviation.Length);
 }
Ejemplo n.º 31
0
        public JinxBotClient(ClientProfile profile)
        {
            m_activePlugins = new Dictionary <ProfilePluginConfiguration, IJinxBotPlugin>();

            if (profile.SimulateClient)
            {
                m_client = new SimulatedBattleNetClient(profile);
            }
            else
            {
                m_client = new BattleNetClient(profile);
            }

            m_profile          = profile;
            m_resourceProvider = ProfileResourceProvider.RegisterProvider(m_client);
            m_cmdTranslator    = new CommandTranslator(this);

            bool hasSetCommandQueue = false;

            if (m_database == null)
            {
                m_database = new JinxBotDefaultDatabase();
            }

            // finally, initialize ui
            m_window = new ProfileDocument(this);

            // initialize plugins
            m_commandHandlers = new List <ICommandHandler>();
            foreach (ProfilePluginConfiguration pluginConfig in profile.PluginSettings)
            {
                hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, pluginConfig);
            }

            ProfilePluginConfiguration jsConfig = new ProfilePluginConfiguration
            {
                Assembly = "JinxBot.Plugins.Script.dll",
                Name     = "JavaScript Plugin",
                Settings = new ProfilePluginSettingConfiguration[0],
                Type     = "JinxBot.Plugins.Script.JinxBotJavaScriptPlugin"
            };

            hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, jsConfig);

            if (!hasSetCommandQueue)
            {
                m_client.CommandQueue = new TimedMessageQueue();
            }
        }
Ejemplo n.º 32
0
 public virtual void UnregisterPackets(BattleNetClient client)
 {
     lock (m_registrationSync)
     {
         if (m_registered)
         {
             client.UnregisterCustomPacketHandler(BncsPacketId.LogonRealmEx, m_oldLogonRealmEx);
             client.UnregisterCustomPacketHandler(BncsPacketId.AuthInfo, m_oldAuthInfo);
             client.UnregisterCustomPacketHandler(BncsPacketId.QueryRealms2, m_oldQueryRealms);
             client.UnregisterCustomPacketHandler(BncsPacketId.LogonResponse2, m_oldLogonResponse2);
             m_registered = false;
             m_client     = null;
         }
     }
 }
Ejemplo n.º 33
0
 public virtual void UnregisterPackets(BattleNetClient client)
 {
     lock (m_registrationSync)
     {
         if (m_registered)
         {
             client.UnregisterCustomPacketHandler(BncsPacketId.LogonRealmEx, m_oldLogonRealmEx);
             client.UnregisterCustomPacketHandler(BncsPacketId.AuthInfo, m_oldAuthInfo);
             client.UnregisterCustomPacketHandler(BncsPacketId.QueryRealms2, m_oldQueryRealms);
             client.UnregisterCustomPacketHandler(BncsPacketId.LogonResponse2, m_oldLogonResponse2);
             m_registered = false;
             m_client = null;
         }
     }
 }
Ejemplo n.º 34
0
        public virtual void RegisterPackets(BattleNetClient client)
        {
            lock (m_registrationSync)
            {
                if (!m_registered)
                {
                    m_client = client;

                    m_events = client.RegisterCustomPacketHandler(BncsPacketId.LogonResponse2, __LogonResponse2, out m_oldLogonResponse2);
                    client.RegisterCustomPacketHandler(BncsPacketId.QueryRealms2, __QueryRealms2, out m_oldQueryRealms);
                    client.RegisterCustomPacketHandler(BncsPacketId.AuthInfo, __AuthInfo, out m_oldAuthInfo);
                    client.RegisterCustomPacketHandler(BncsPacketId.LogonRealmEx, __LogonRealmEx, out m_oldLogonRealmEx);
                    m_registered = true;
                }
            }
        }
Ejemplo n.º 35
0
 // Methods
 public NotifyJoin(byte[] data)
     : base(data)
 {
     this.client = (BattleNetClient) BitConverter.ToUInt32(data, 3);
     this.version = BitConverter.ToUInt32(data, 7);
     this.name = ByteConverter.GetNullString(data, 11);
     this.password = ByteConverter.GetNullString(data, 12 + this.name.Length);
 }
Ejemplo n.º 36
0
 // Methods
 public DisplayAd(byte[] data)
     : base(data)
 {
     this.platform = (BattleNetPlatform) BitConverter.ToUInt32(data, 3);
     this.client = (BattleNetClient) BitConverter.ToUInt32(data, 7);
     this.id = BitConverter.ToUInt32(data, 11);
     if (data[15] != 0)
     {
     this.filename = ByteConverter.GetNullString(data, 15);
     }
     int index = 0x10 + ((this.filename == null) ? 0 : this.filename.Length);
     if (data[index] != 0)
     {
     this.url = ByteConverter.GetNullString(data, index);
     }
 }
Ejemplo n.º 37
0
 // Methods
 public ChannelListRequest(byte[] data)
     : base(data)
 {
     this.client = (BattleNetClient)BitConverter.ToUInt32(data, 3);
 }
Ejemplo n.º 38
0
 // Methods
 public BnetConnectionRequest(byte[] data)
     : base(data)
 {
     this.protocol = BitConverter.ToUInt32(data, 3);
     this.platform = (BattleNetPlatform) BitConverter.ToUInt32(data, 7);
     this.client = (BattleNetClient) BitConverter.ToUInt32(data, 11);
     this.version = BitConverter.ToUInt32(data, 15);
     this.language = BitConverter.ToUInt32(data, 0x13);
     this.localIP = new System.Net.IPAddress((long)BitConverter.ToUInt32(data, 0x17));
     this.timeZoneBias = BitConverter.ToUInt32(data, 0x1b);
     this.localeID = BitConverter.ToUInt32(data, 0x1f);
     this.languageID = BitConverter.ToUInt32(data, 0x23);
     this.countryAbbreviation = ByteConverter.GetNullString(data, 0x27);
     this.countryName = ByteConverter.GetNullString(data, 40 + this.countryAbbreviation.Length);
 }
Ejemplo n.º 39
0
        static void Main(string[] args)
        {
            Console.WriteLine("Logging on with Starcraft; enter CD key.");
            string cdKey = Console.ReadLine().Trim();
            Console.WriteLine("Enter account name:");
            string acct = Console.ReadLine().Trim();
            Console.WriteLine("Enter account password for {0}:", acct);
            string password = Console.ReadLine().Trim();

            Settings set = new Settings() { CdKey1 = cdKey, Username = acct, Password = password, CdKeyOwner = acct };

            BattleNetClient client = new BattleNetClient(set);
            client.Connected += delegate { Console.WriteLine("--- CONNECTED"); };
            client.Error += new ErrorEventHandler(client_Error);
            client.EnteredChat += new EnteredChatEventHandler(client_EnteredChat);
            client.LoginSucceeded += new EventHandler(client_LoginSucceeded);
            client.LoginFailed += new LoginFailedEventHandler(client_LoginFailed);
            client.ServerBroadcast += new ServerChatEventHandler(client_ServerBroadcast);
            client.ServerErrorReceived += new ServerChatEventHandler(client_ServerErrorReceived);
            client.UserShown += new UserEventHandler(client_UserShown);
            client.UserJoined += new UserEventHandler(client_UserJoined);
            client.UserLeft += new UserEventHandler(client_UserLeft);
            client.UserSpoke += new ChatMessageEventHandler(client_UserSpoke);
            client.UserEmoted += new ChatMessageEventHandler(client_UserEmoted);
            client.ClientCheckPassed += delegate { Console.WriteLine("--- VERSIONING PASSED"); };
            client.ClientCheckFailed += new ClientCheckFailedEventHandler(client_ClientCheckFailed);
            client.JoinedChannel += new ServerChatEventHandler(client_JoinedChannel);
            client.WardentUnhandled += delegate { Console.WriteLine("--- WARNING: Warden requested and unhandled!!"); };
            client.MessageSent += new ChatMessageEventHandler(client_MessageSent);
            client.Disconnected += delegate { Console.WriteLine("--- DISCONNECTED"); };

            BattleNetClientResources.IncomingBufferPool.NewBufferAllocated += new EventHandler(BufferAllocated);
            BattleNetClientResources.OutgoingBufferPool.NewBufferAllocated += new EventHandler(BufferAllocated);

            Console.WriteLine("Events hooked up; press <enter> to connect.");
            Console.ReadLine();

            Console.WriteLine("Type /exit to quit.");

            client.Connect();

            string text;
            bool exit = false;
            do
            {
                text = Console.ReadLine();
                if (!text.Equals("/exit", StringComparison.Ordinal))
                {
                    client.SendMessage(text);
                }
                else
                {
                    exit = true;
                }
            } while (!exit);

            client.Close();
            Console.WriteLine("Disconnected; press <enter> to exit.");
            Console.ReadLine();

        }
Ejemplo n.º 40
0
 // Methods
 public ChatEvent(byte[] data)
     : base(data)
 {
     this.clientVersion = -1;
     this.characterType = BattleNetCharacter.Unknown;
     this.characterLevel = -1;
     this.characterAct = -1;
     this.characterTitle = CharacterTitle.None;
     this.eventType = (ChatEventType) BitConverter.ToUInt32(data, 3);
     this.flags = BitConverter.ToUInt32(data, 7);
     this.ping = BitConverter.ToUInt32(data, 11);
     int length = ByteConverter.GetByteOffset(data, 0, 0x1b);
     int num2 = ByteConverter.GetByteOffset(data, 0x2a, 0x1b, length);
     if (num2 > 0)
     {
     this.name = ByteConverter.GetString(data, 0x1b, num2);
     length -= num2 + 1;
     num2 += 0x1c;
     }
     else if (num2 == 0)
     {
     num2 = 0x1c;
     length--;
     this.characterType = BattleNetCharacter.OpenCharacter;
     }
     else
     {
     num2 = 0x1b;
     }
     this.account = ByteConverter.GetString(data, num2, length);
     length += num2 + 1;
     if (this.eventType != ChatEventType.ChannelLeave)
     {
     if ((this.eventType == ChatEventType.ChannelJoin) || (this.eventType == ChatEventType.ChannelUser))
     {
         if ((data.Length - length) > 3)
         {
             this.client = (BattleNetClient) BitConverter.ToUInt32(data, length);
             length += 4;
         }
         if ((((this.client != BattleNetClient.StarcraftShareware) && (this.client != BattleNetClient.Starcraft)) && (this.client != BattleNetClient.StarcraftBroodWar)) && ((this.client == BattleNetClient.Diablo2) || (this.client == BattleNetClient.Diablo2LoD)))
         {
             if (this.client == BattleNetClient.Diablo2LoD)
             {
                 this.characterFlags |= CharacterFlags.Expansion;
             }
             if ((data.Length - length) >= 4)
             {
                 this.realm = ByteConverter.GetString(data, length, -1, 0x2c);
                 length += this.realm.Length + 1;
                 if (data.Length >= length)
                 {
                     length += ByteConverter.GetByteOffset(data, 0x2c, length) + 1;
                     if (((length != -1) && (data.Length > length)) && ((data.Length - length) >= 0x21))
                     {
                         StatString.ParseD2StatString(data, length, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
                     }
                 }
             }
         }
     }
     else
     {
         this.message = ByteConverter.GetNullString(data, length);
     }
     }
 }
Ejemplo n.º 41
0
 // Methods
 public EnterChatResponse(byte[] data)
     : base(data)
 {
     this.clientVersion = -1;
     this.characterType = BattleNetCharacter.Unknown;
     this.characterLevel = -1;
     this.characterAct = -1;
     this.characterTitle = CharacterTitle.None;
     this.username = ByteConverter.GetNullString(data, 3);
     int startIndex = 4 + this.username.Length;
     this.client = (BattleNetClient) BitConverter.ToUInt32(data, startIndex);
     if (data[startIndex += 4] == 0)
     {
     this.account = ByteConverter.GetNullString(data, startIndex + 1);
     }
     else
     {
     this.realm = ByteConverter.GetString(data, startIndex, -1, 0x2c);
     startIndex += 1 + this.realm.Length;
     this.name = ByteConverter.GetString(data, startIndex, -1, 0x2c);
     startIndex += 1 + this.name.Length;
     int num2 = ByteConverter.GetByteOffset(data, 0, startIndex);
     this.account = ByteConverter.GetNullString(data, (startIndex + num2) + 1);
     if (this.client == BattleNetClient.Diablo2LoD)
     {
         this.characterFlags |= CharacterFlags.Expansion;
     }
     StatString.ParseD2StatString(data, startIndex, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
     }
 }