Exemplo n.º 1
0
        public void Load(S.ObjectNPC info)
        {
            Name = info.Name;
            NameColour = info.NameColour;

            CurrentLocation = info.Location;
            Movement = info.Location;
            MapLocation = info.Location;
            GameScene.Scene.MapControl.AddObject(this);
            Direction = info.Direction;
            if (info.Image < Libraries.NPCs.Length)
                BodyLibrary = Libraries.NPCs[info.Image];

            switch (info.Image)
            {
                case 23:
                    Frames = FrameSet.NPCs[1];
                    break;
                default:
                    Frames = FrameSet.NPCs[0];
                    break;
            }

            Light = 10;

            SetAction();
        }
Exemplo n.º 2
0
        public void Load(S.ObjectSpell info)
        {
            CurrentLocation = info.Location;
            MapLocation = info.Location;
            GameScene.Scene.MapControl.AddObject(this);
            Spell = info.Spell;

            switch (Spell)
            {
                case Spell.TrapHexagon:
                    BodyLibrary = Libraries.Magic;
                    DrawFrame = 1390;
                    FrameInterval = 100;
                    FrameCount = 10;
                    break;
                case Spell.FireWall:
                    BodyLibrary = Libraries.Magic;
                    DrawFrame = 1630;
                    FrameInterval = 120;
                    FrameCount = 6;
                    Light = 3;
                    break;
                case Spell.PoisonField:
                    BodyLibrary = Libraries.Magic2;
                    DrawFrame = 1650;
                    FrameInterval = 120;
                    FrameCount = 20;
                    Light = 3;
                    break;
            }

            NextMotion = CMain.Time + FrameInterval;
            NextMotion -= NextMotion % 100;
        }
Exemplo n.º 3
0
        public void Load(S.ObjectGold info)
        {
            Name = string.Format("Gold ({0:###,###,###})", info.Gold);


            BodyLibrary = Libraries.FloorItems;

            CurrentLocation = info.Location;
            MapLocation = info.Location;
            GameScene.Scene.MapControl.AddObject(this);

            if (info.Gold < 100)
                DrawFrame = 112;
            else if (info.Gold < 200)
                DrawFrame = 113;
            else if (info.Gold < 500)
                DrawFrame = 114;
            else if (info.Gold < 1000)
                DrawFrame = 115;
            else
                DrawFrame = 116;

            Size = BodyLibrary.GetTrueSize(DrawFrame);

            DrawY = CurrentLocation.Y;
        }
Exemplo n.º 4
0
        public void Load(S.ObjectDeco info)
        {
            CurrentLocation = info.Location;
            MapLocation = info.Location;
            GameScene.Scene.MapControl.AddObject(this);
            Image = info.Image;

            BodyLibrary = Libraries.Deco;
        }
Exemplo n.º 5
0
        public void Load(S.UserInformation info)
        {
            Id = info.RealId;
            Name = info.Name;
            Settings.LoadTrackedQuests(info.Name);
            NameColour = info.NameColour;
            GuildName = info.GuildName;
            GuildRankName = info.GuildRank;
            Class = info.Class;
            Gender = info.Gender;
            Level = info.Level;

            CurrentLocation = info.Location;
            MapLocation = info.Location;
            GameScene.Scene.MapControl.AddObject(this);

            Direction = info.Direction;
            Hair = info.Hair;

            HP = info.HP;
            MP = info.MP;

            Experience = info.Experience;
            MaxExperience = info.MaxExperience;

            LevelEffects = info.LevelEffects;

            Inventory = info.Inventory;
            Equipment = info.Equipment;
            QuestInventory = info.QuestInventory;

            Magics = info.Magics;
            for (int i = 0; i < Magics.Count; i++ )
            {
                if (Magics[i].CastTime > 0)
                    Magics[i].CastTime = CMain.Time - Magics[i].CastTime;
            }

            IntelligentCreatures = info.IntelligentCreatures;//IntelligentCreature
            SummonedCreatureType = info.SummonedCreatureType;//IntelligentCreature
            CreatureSummoned = info.CreatureSummoned;//IntelligentCreature

            BindAllItems();

            RefreshStats();

            SetAction();
        }
Exemplo n.º 6
0
        public void Load(S.ObjectItem info)
        {
            Name = info.Name;
            NameColour = info.NameColour;

            BodyLibrary = Libraries.FloorItems;

            CurrentLocation = info.Location;
            MapLocation = info.Location;
            GameScene.Scene.MapControl.AddObject(this);
            DrawFrame = info.Image;

            Size = BodyLibrary.GetTrueSize(DrawFrame);

            DrawY = CurrentLocation.Y;
        }
Exemplo n.º 7
0
        private void MailCost(S.MailCost p)
        {
            if(GameScene.Scene.MailComposeParcelDialog.Visible)
            {
                if (p.Cost > 0)
                    SoundManager.PlaySound(SoundList.Gold);

                GameScene.Scene.MailComposeParcelDialog.ParcelCostLabel.Text = p.Cost.ToString();
            }
        }
Exemplo n.º 8
0
 private void ParcelCollected(S.ParcelCollected p)
 {
     switch(p.Result)
     {
         case -1:
             MirMessageBox messageBox = new MirMessageBox(string.Format("No parcels to collect."), MirMessageBoxButtons.OK);
             messageBox.Show();
             break;
         case 0:
             messageBox = new MirMessageBox(string.Format("All parcels have been collected."), MirMessageBoxButtons.OK);
             messageBox.Show();
             break;
         case 1:
             GameScene.Scene.MailReadParcelDialog.Hide();
             break;
     }
 }
Exemplo n.º 9
0
 private void button_dead_clanhall_Click(object sender, System.EventArgs e)
 {
     //return to clanhall
     ServerPackets.Return(1);
     panel_dead.Hide();
 }
Exemplo n.º 10
0
        private void DeleteCharacter(S.DeleteCharacterSuccess p)
        {
            DeleteCharacterButton.Enabled = true;
            MirMessageBox.Show("Your character was deleted successfully.");

            for (int i = 0; i < Characters.Count; i++)
                if (Characters[i].Index == p.CharacterIndex)
                {
                    Characters.RemoveAt(i);
                    break;
                }

            UpdateInterface();
        }
Exemplo n.º 11
0
        public void MountUpdate(S.MountUpdate info)
        {
            MountType = info.MountType;
            RidingMount = info.RidingMount;

            QueuedAction action = new QueuedAction { Action = MirAction.Standing, Direction = Direction, Location = CurrentLocation };
            ActionFeed.Insert(0, action);

            MountTime = CMain.Time;

            if (MountType < 0)
                GameScene.Scene.MountDialog.Hide();

            SetLibraries();
            SetEffects();

            PlayMountSound();
        }
Exemplo n.º 12
0
        public void Load(S.ObjectPlayer info)
        {
            Name = info.Name;
            NameColour = info.NameColour;
            Class = info.Class;
            Gender = info.Gender;

            CurrentLocation = info.Location;
            MapLocation = info.Location;
            GameScene.Scene.MapControl.AddObject(this);

            Direction = info.Direction;
            Hair = info.Hair;

            Weapon = info.Weapon;
            Armour = info.Armour;
            Light = info.Light;

            Poison = info.Poison;

            Dead = info.Dead;
            Hidden = info.Hidden;

            WingEffect = info.WingEffect;

            SetLibraries();

            if (Dead) ActionFeed.Add(new QueuedAction { Action = MirAction.Dead, Direction = Direction, Location = CurrentLocation });
            if (info.Extra) Effects.Add(new Effect(Libraries.Magic2, 670, 10, 800, this));

            SetAction();
        }
Exemplo n.º 13
0
 private void LoverUpdate(S.LoverUpdate p)
 {
     GameScene.Scene.RelationshipDialog.LoverName = p.Name;
     GameScene.Scene.RelationshipDialog.Date = p.Date;
     GameScene.Scene.RelationshipDialog.MapName = p.MapName;
     GameScene.Scene.RelationshipDialog.UpdateInterface();
 }
Exemplo n.º 14
0
 private void button_social_laugh_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialLaugh();
 }
Exemplo n.º 15
0
 private void button_social_waiting_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialWaiting();
 }
Exemplo n.º 16
0
 private void button_social_unaware_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialUnaware();
 }
Exemplo n.º 17
0
 internal void WriteInteger(ServerPackets sConnectionOK)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 18
0
    void NotifyEntities(Server server, int clientid, float dt)
    {
        ClientOnServer c = server.clients[clientid];

        c.notifyEntitiesAccum += dt;
        if (c.notifyEntitiesAccum < (one / EntityPositionUpdatesPerSecond))
        {
            return;
        }
        c.notifyEntitiesAccum = 0;

        // find nearest entities
        int max = SpawnMaxEntities;

        ServerEntityId[] nearestEntities = new ServerEntityId[max];
        FindNearEntities(server, c, max, nearestEntities);

        // update entities
        for (int i = 0; i < max; i++)
        {
            ServerEntityId e = nearestEntities[i];
            if (e == null)
            {
                continue;
            }
            for (int k = 0; k < server.modEventHandlers.onupdateentity.Count; k++)
            {
                server.modEventHandlers.onupdateentity[k](e.chunkx, e.chunky, e.chunkz, e.id);
            }
        }

        // despawn old entities
        for (int i = 0; i < c.spawnedEntitiesCount; i++)
        {
            ServerEntityId e = c.spawnedEntities[i];
            if (e == null)
            {
                continue;
            }
            if (!Contains(nearestEntities, max, e))
            {
                int onClientId = i;
                c.spawnedEntities[onClientId] = null;
                server.SendPacket(clientid, ServerPackets.EntityDespawn(64 + onClientId));
            }
        }

        // spawn new entities
        for (int i = 0; i < max; i++)
        {
            ServerEntityId e = nearestEntities[i];
            if (e == null)
            {
                continue;
            }
            if (!Contains(c.spawnedEntities, max, e))
            {
                int onClientId = IndexOfNull(c.spawnedEntities, c.spawnedEntitiesCount);
                c.spawnedEntities[onClientId] = e.Clone();
                ServerChunk         chunk = server.d_Map.GetChunk(e.chunkx * Server.chunksize, e.chunky * Server.chunksize, e.chunkz * Server.chunksize);
                ServerEntity        ee    = chunk.Entities[e.id];
                Packet_ServerEntity ne    = ToNetworkEntity(server.serverPlatform, ee);
                server.SendPacket(clientid, ServerPackets.EntitySpawn(64 + onClientId, ne));
            }
        }

        for (int i = 0; i < max; i++)
        {
            if (c.updateEntity[i])
            {
                c.updateEntity[i] = false;
                ServerEntityId      e     = c.spawnedEntities[i];
                ServerChunk         chunk = server.d_Map.GetChunk(e.chunkx * Server.chunksize, e.chunky * Server.chunksize, e.chunkz * Server.chunksize);
                ServerEntity        ee    = chunk.Entities[e.id];
                Packet_ServerEntity ne    = ToNetworkEntity(server.serverPlatform, ee);
                server.SendPacket(clientid, ServerPackets.EntitySpawn(64 + i, ne));
            }
        }
    }
Exemplo n.º 19
0
 public void DisconnectPlayer(int player, string message)
 {
     server.SendPacket(player, ServerPackets.DisconnectPlayer(message));
     server.KillPlayer(player);
 }
Exemplo n.º 20
0
        private void UpdateIntelligentCreatureList(S.UpdateIntelligentCreatureList p)//IntelligentCreature
        {
            User.CreatureSummoned = p.CreatureSummoned;
            User.SummonedCreatureType = p.SummonedCreatureType;
            User.PearlCount = p.PearlCount;
            if (p.CreatureList.Count != User.IntelligentCreatures.Count)
            {
                User.IntelligentCreatures.Clear();
                for (int i = 0; i < p.CreatureList.Count; i++)
                    User.IntelligentCreatures.Add(p.CreatureList[i]);

                for (int i = 0; i < IntelligentCreatureDialog.CreatureButtons.Length; i++)
                    IntelligentCreatureDialog.CreatureButtons[i].Clear();

                IntelligentCreatureDialog.Hide();
            }
            else
            {
                for (int i = 0; i < p.CreatureList.Count; i++)
                    User.IntelligentCreatures[i] = p.CreatureList[i];
                if (IntelligentCreatureDialog.Visible) IntelligentCreatureDialog.Update();
            }
        }
Exemplo n.º 21
0
        private void NPCPearlGoods(S.NPCPearlGoods p)//pearl currency
        {
            for (int i = 0; i < p.List.Count; i++)
            {
                p.List[i].Info = GetInfo(p.List[i].ItemIndex);
            }

            NPCRate = p.Rate;
            if (!NPCDialog.Visible) return;
            NPCGoodsDialog.usePearls = true;
            NPCGoodsDialog.NewGoods(p.List);
            NPCGoodsDialog.Show();
        }
Exemplo n.º 22
0
 private void button_social_clap_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialApplause();
 }
Exemplo n.º 23
0
 private void GameShopUpdate(S.GameShopInfo p)
 {
     p.Item.Stock = p.StockLevel;
     GameShopInfoList.Add(p.Item);
     if (p.Item.Date > DateTime.Now.AddDays(-7)) GameShopDialog.New.Visible = true;
 }
Exemplo n.º 24
0
 private void button_social_sorrow_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialSad();
 }
Exemplo n.º 25
0
        public void Update(S.PlayerUpdate info)
        {
            Weapon = info.Weapon;
            Armour = info.Armour;
            Light = info.Light;
            WingEffect = info.WingEffect;

            SetLibraries();
            SetEffects();
        }
Exemplo n.º 26
0
 private void button_social_shyness_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialShyness();
 }
Exemplo n.º 27
0
 private void NewCharacter(S.NewCharacterSuccess p)
 {
     _character.Dispose();
     MirMessageBox.Show("Your character was created successfully.");
     
     Characters.Insert(0, p.CharInfo);
     _selected = 0;
     UpdateInterface();
 }
Exemplo n.º 28
0
        /* End */

        private void button_sit_stand_Click(object sender, EventArgs e)
        {
            ServerPackets.Use_Action_Parse((uint)PClientAction.SitStand, false, false);
        }
Exemplo n.º 29
0
 private void button_dead_fort_Click(object sender, EventArgs e)
 {
     //return to fortress
     ServerPackets.Return(4);
     panel_dead.Hide();
 }
Exemplo n.º 30
0
 private void button_walk_run_Click(object sender, EventArgs e)
 {
     ServerPackets.Use_Action_Parse((int)PClientAction.RunWalk, false, false);
 }
Exemplo n.º 31
0
 private void button_dead_town_Click(object sender, System.EventArgs e)
 {
     //return to town
     ServerPackets.Return(0);
     panel_dead.Hide();
 }
Exemplo n.º 32
0
 private void button_assist_Click(object sender, EventArgs e)
 {
     ServerPackets.Assist();
 }
Exemplo n.º 33
0
 private void ResizeInventory(S.ResizeInventory p)
 {
     Array.Resize(ref User.Inventory, p.Size);
     InventoryDialog.RefreshInventory2();
 }
Exemplo n.º 34
0
 private void button_recommend_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_Evaluate(Globals.gamedata.my_char.TargetID);
 }
Exemplo n.º 35
0
        private void NewIntelligentCreature(S.NewIntelligentCreature p)//IntelligentCreature
        {
            User.IntelligentCreatures.Add(p.Creature);

            MirInputBox inputBox = new MirInputBox("Please give your creature a name.");
            inputBox.InputTextBox.Text = GameScene.User.IntelligentCreatures[User.IntelligentCreatures.Count-1].CustomName;
            inputBox.OKButton.Click += (o1, e1) =>
            {
                if (IntelligentCreatureDialog.Visible) IntelligentCreatureDialog.Update();//refresh changes
                GameScene.User.IntelligentCreatures[User.IntelligentCreatures.Count - 1].CustomName = inputBox.InputTextBox.Text;
                Network.Enqueue(new C.UpdateIntelligentCreature { Creature = GameScene.User.IntelligentCreatures[User.IntelligentCreatures.Count - 1] });
                inputBox.Dispose();
            };
            inputBox.Show();
        }
Exemplo n.º 36
0
 private void button_party_leave_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_Leave();
 }
Exemplo n.º 37
0
 private void IntelligentCreatureEnableRename(S.IntelligentCreatureEnableRename p)//IntelligentCreature
 {
     IntelligentCreatureDialog.CreatureRenameButton.Visible = true;
     if (IntelligentCreatureDialog.Visible) IntelligentCreatureDialog.Update();
 }
Exemplo n.º 38
0
 private void button_party_dismiss_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_Dismiss(Util.GetCharName(Globals.gamedata.my_char.TargetID));
 }
Exemplo n.º 39
0
        private void FriendUpdate(S.FriendUpdate p)
        {
            GameScene.Scene.FriendDialog.Friends = p.Friends;

            if (GameScene.Scene.FriendDialog.Visible)
            {
                GameScene.Scene.FriendDialog.Update(false);
            }
        }
Exemplo n.º 40
0
 private void button_party_changeleader_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_ChangePartyLeader(Util.GetCharName(Globals.gamedata.my_char.TargetID));
 }
Exemplo n.º 41
0
        private void MentorUpdate(S.MentorUpdate p)
        {
            GameScene.Scene.MentorDialog.MentorName = p.Name;
            GameScene.Scene.MentorDialog.MentorLevel = p.Level;
            GameScene.Scene.MentorDialog.MentorOnline = p.Online;
            GameScene.Scene.MentorDialog.MenteeEXP = p.MenteeEXP;

            GameScene.Scene.MentorDialog.UpdateInterface();
        }
Exemplo n.º 42
0
 private void button_social_hello_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialHello();
 }
Exemplo n.º 43
0
        private void GameShopStock(S.GameShopStock p)
        {
            for (int i = 0; i < GameShopInfoList.Count; i++)
            {
                if (GameShopInfoList[i].GIndex == p.GIndex)
                    {
                    if (p.StockLevel == 0) GameShopInfoList.Remove(GameShopInfoList[i]);
                    else GameShopInfoList[i].Stock = p.StockLevel;

                    if (GameShopDialog.Visible) GameShopDialog.UpdateShop();
                    }
            }
        }
Exemplo n.º 44
0
 private void button_social_victory_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialVictory();
 }
Exemplo n.º 45
0
        public void FishingUpdate(S.FishingUpdate p)
        {
            if (Fishing != p.Fishing)
            {
                MirDirection dir = Functions.DirectionFromPoint(CurrentLocation, p.FishingPoint);

                if (p.Fishing)
                {
                    QueuedAction action = new QueuedAction { Action = MirAction.FishingCast, Direction = dir, Location = CurrentLocation };
                    ActionFeed.Add(action);
                }
                else
                {
                    QueuedAction action = new QueuedAction { Action = MirAction.FishingReel, Direction = dir, Location = CurrentLocation };
                    ActionFeed.Add(action);

                    if (p.FoundFish)
                        GameScene.Scene.ChatDialog.ReceiveChat("Found fish!!", ChatType.Hint);
                }

                Fishing = p.Fishing;
                SetLibraries();
            }

            if (!HasFishingRod)
            {
                GameScene.Scene.FishingDialog.Hide();
            }

            FishingPoint = p.FishingPoint;
            FoundFish = p.FoundFish;
        }
Exemplo n.º 46
0
 private void button_social_advance_Click(object sender, EventArgs e)
 {
     ServerPackets.Command_SocialCharge();
 }
Exemplo n.º 47
0
        public void Load(S.ObjectPlayer info)
        {
            Name = info.Name;
            NameColour = info.NameColour;
            GuildName = info.GuildName;
            GuildRankName = info.GuildRankName;
            Class = info.Class;
            Gender = info.Gender;
            Level = info.Level;

            CurrentLocation = info.Location;
            MapLocation = info.Location;
            GameScene.Scene.MapControl.AddObject(this);

            Direction = info.Direction;
            Hair = info.Hair;

            Weapon = info.Weapon;
            Armour = info.Armour;
            Light = info.Light;

            Poison = info.Poison;

            Dead = info.Dead;
            Hidden = info.Hidden;

            WingEffect = info.WingEffect;
            CurrentEffect = info.Effect;

            MountType = info.MountType;
            RidingMount = info.RidingMount;

            Fishing = info.Fishing;

            TransformType = info.TransformType;

            SetLibraries();

            if (Dead) ActionFeed.Add(new QueuedAction { Action = MirAction.Dead, Direction = Direction, Location = CurrentLocation });
            if (info.Extra) Effects.Add(new Effect(Libraries.Magic2, 670, 10, 800, this));

            ElementEffect = (int)info.ElementOrbEffect;
            ElementsLevel = (int)info.ElementOrbLvl;
            ElementOrbMax = (int)info.ElementOrbMax;

            Buffs = info.Buffs;

            LevelEffects = info.LevelEffects;

            ProcessBuffs();

            SetAction();

            SetEffects();
        }
Exemplo n.º 48
0
        public void StartGame(S.StartGameBanned p)
        {
            StartGameButton.Enabled = true;

            TimeSpan d = p.ExpiryDate - CMain.Now;
            MirMessageBox.Show(string.Format("This account is banned.\n\nReason: {0}\nExpiryDate: {1}\nDuration: {2:#,##0} Hours, {3} Minutes, {4} Seconds", p.Reason,
                                             p.ExpiryDate, Math.Floor(d.TotalHours), d.Minutes, d.Seconds));
        }
Exemplo n.º 49
0
        private void NewCharacter(S.NewCharacter p)
        {
            _character.OKButton.Enabled = true;
            
            switch (p.Result)
            {
                case 0:
                    MirMessageBox.Show("Creating new characters is currently disabled.");
                    _character.Dispose();
                    break;
                case 1:
                    MirMessageBox.Show("Your Character Name is not acceptable.");
                    _character.NameTextBox.SetFocus();
                    break;
                case 2:
                    MirMessageBox.Show("The gender you selected does not exist.\n Contact a GM for assistance.");
                    break;
                case 3:
                    MirMessageBox.Show("The class you selected does not exist.\n Contact a GM for assistance.");
                    break;
                case 4:
                    MirMessageBox.Show("You cannot make anymore then " + Globals.MaxCharacterCount + " Characters.");
                    _character.Dispose();
                    break;
                case 5:
                    MirMessageBox.Show("A Character with this name already exists.");
                    _character.NameTextBox.SetFocus();
                    break;
            }


        }
Exemplo n.º 50
0
        private void ClientReadThread()
        {
            byte[] buffread = new byte[Globals.BUFFER_MAX];
            byte[] buffpacket;
            byte[] buffpacketin;

            int  cnt     = 0;
            int  size    = 0;
            int  ggcnt   = 0;
            bool forward = true;

            ByteBuffer bbuffer0;

            System.Text.StringBuilder dumpbuilder;

            //Add_Text("Welcome to the game loop",Color.Red);

            try
            {
                while (Globals.gamedata.running && !Globals.gamedata.OOG)
                {
                    cnt += Globals.Game_ClientSocket.Receive(buffread, cnt, Globals.BUFFER_PACKET - cnt, System.Net.Sockets.SocketFlags.None);
                    size = System.BitConverter.ToUInt16(buffread, 0);

                    while (cnt >= size && cnt > 2)
                    {
                        //if we got partial shit we cant use, read some more until it is full
                        while (size > cnt)
                        {
                            cnt += Globals.Game_ClientSocket.Receive(buffread, cnt, Globals.BUFFER_PACKET - cnt, System.Net.Sockets.SocketFlags.None);
                        }

                        buffpacketin = new byte[size - 2];
                        buffpacket   = new byte[size - 2];

                        Array.Copy(buffread, 2, buffpacketin, 0, size - 2);

                        Globals.gamedata.crypt_clientin.decrypt(buffpacketin);

                        Array.Copy(buffpacketin, 0, buffpacket, 0, size - 2);

                        if (Globals.Mixer != null)
                        {
                            Globals.Mixer.Decrypt0(buffpacket);
                        }
                        if (Globals.pck_thread.pck_recording)
                        {
                            pck_window_dat pck_dat = new pck_window_dat(buffpacket);
                            pck_dat.action = 1;
                            pck_dat.type   = 1;
                            pck_dat.time   = System.DateTime.Now.TimeOfDay.ToString();
                            Globals.pck_thread.mine_queue.Enqueue(pck_dat);
                        }
#if DEBUG
                        try
                        {
                            //

                            /* if (Globals.pck_thread.pck_recording)
                             * {
                             * // *                             lock (Globals.pck_thread.lock_obj)
                             * // {
                             *    pck_window_dat pck_dat = new pck_window_dat(buffpacket);
                             *    pck_dat.action = 1;
                             *    pck_dat.type = 1;
                             *    pck_dat.time = System.DateTime.Now.TimeOfDay.ToString();
                             *    Globals.pck_thread.mine_queue.Enqueue(pck_dat);
                             * //* }
                             * }*/
                            //
                            Globals.clientdataout.WriteLine("packet...-size: " + size.ToString() + " -count:" + cnt.ToString() + " :::time:::" + System.DateTime.Now.TimeOfDay.ToString() + ":::");
                            Globals.clientdataout.WriteLine("-data from client to bot hex-");
                            for (uint i = 0; i < size - 2; i++)
                            {
                                Globals.clientdataout.Write(buffpacket[i].ToString("X2"));
                                Globals.clientdataout.Write(" ");
                            }
                            Globals.clientdataout.WriteLine("");
                            Globals.clientdataout.WriteLine("-data from client to bot string-");
                            for (uint i = 0; i < size - 2; i++)
                            {
                                Globals.clientdataout.Write((char)buffpacket[i]);
                            }
                            Globals.clientdataout.WriteLine("");
                        }
                        catch
                        {
                            //failed to write... oh well
                        }
#endif

                        if (Globals.DumpModeClient)
                        {
                            dumpbuilder = new System.Text.StringBuilder();

                            for (int i = 0; i < size - 2; i++)
                            {
                                dumpbuilder.Append(buffpacket[i].ToString("X2"));
                                dumpbuilder.Append(" ");
                            }
                            Globals.l2net_home.Add_Dump(dumpbuilder.ToString(), false);
                        }

                        //shift the data over by size
                        for (uint i = 0; i < cnt - size; i++)
                        {
                            buffread[i] = buffread[size + i];
                        }

                        cnt -= size;

                        if (buffpacket.Length > 0)
                        {
                            forward = true;

                            if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
                            {
                                if ((PClient)buffpacket[0] == PClient.EXPacket)
                                {
                                    if (ScriptEngine.Blocked_ClientPacketsEX.ContainsKey(System.Convert.ToInt32(buffpacket[1])))
                                    {
                                        forward = false;
                                    }

                                    if (ScriptEngine.ClientPacketsEXContainsKey(System.Convert.ToInt32(buffpacket[1])))
                                    {
                                        ByteBuffer bb = new ByteBuffer(buffpacket);

                                        ScriptEvent sc_ev = new ScriptEvent();
                                        sc_ev.Type  = EventType.ClientPacketEX;
                                        sc_ev.Type2 = System.Convert.ToInt32(buffpacket[1]);
                                        sc_ev.Variables.Add(new ScriptVariable(bb, "PACKET", Var_Types.BYTEBUFFER, Var_State.PUBLIC));
                                        sc_ev.Variables.Add(new ScriptVariable(System.DateTime.Now.Ticks, "TIMESTAMP", Var_Types.INT, Var_State.PUBLIC));
                                        ScriptEngine.SendToEventQueue(sc_ev);
                                    }
                                }
                                else
                                {
                                    if (ScriptEngine.Blocked_ClientPackets.ContainsKey(System.Convert.ToInt32(buffpacket[0])))
                                    {
                                        forward = false;
                                    }

                                    if (ScriptEngine.ClientPacketsContainsKey(System.Convert.ToInt32(buffpacket[0])))
                                    {
                                        ByteBuffer bb = new ByteBuffer(buffpacket);

                                        ScriptEvent sc_ev = new ScriptEvent();
                                        sc_ev.Type  = EventType.ClientPacket;
                                        sc_ev.Type2 = System.Convert.ToInt32(buffpacket[0]);
                                        sc_ev.Variables.Add(new ScriptVariable(bb, "PACKET", Var_Types.BYTEBUFFER, Var_State.PUBLIC));
                                        sc_ev.Variables.Add(new ScriptVariable(System.DateTime.Now.Ticks, "TIMESTAMP", Var_Types.INT, Var_State.PUBLIC));
                                        ScriptEngine.SendToEventQueue(sc_ev);
                                    }
                                }
                            }

                            //this is where we would want to handle packets sent by the client
                            switch ((PClient)buffpacket[0])
                            {
                            case PClient.AuthLogin:    //protocol version
                                int prot = System.BitConverter.ToInt16(buffpacket, 1);
                                Globals.l2net_home.Add_Text("protocol version: " + prot.ToString(), Globals.Red, TextType.BOT);

                                if (prot == -2)
                                {
                                    Globals.l2net_home.Add_Text("-2 protocol... just a ping... we've been had XD...", Globals.Red, TextType.BOT);
                                }
                                else
                                {
                                    //valid protocol...
                                    Globals.l2net_home.Add_Text("valid protocol...", Globals.Red, TextType.BOT);
                                }
                                break;

                            case PClient.GameGuardReply:                                    //gameguard reply
                                if (Globals.GG_Servermode)
                                {
                                    if (Globals.GG_QueryReceived)
                                    {
                                        ggcnt++;
                                        if (ggcnt == 1)
                                        {
                                            //GameGuardServer.send_gg_answer(buffpacket, false);
                                            GameGuardServer.SendGGReply(buffpacket);
                                        }

                                        if (ggcnt == 2)
                                        {
                                            Globals.GG_QueryReceived = false;
                                            //GameGuardServer.send_gg_answer(buffpacket, true);
                                            GameGuardServer.SendGGReply(buffpacket);
                                            ggcnt = 0;
                                        }
                                        forward = false;
                                    }
                                }
                                if (Globals.Script_Debugging)
                                {
                                    string gg = "";

                                    for (int i = 1; i < buffpacket.Length; i++)
                                    {
                                        gg += buffpacket[i].ToString("X2") + " ";
                                    }

                                    Globals.l2net_home.Add_Debug("GameGuard Reply: " + gg);
                                }
                                break;

                            case PClient.Say2:                                    //say text
                                if (Globals.gamedata.OOG == false)
                                {
                                    ByteBuffer bbuff = new ByteBuffer(buffpacket);

                                    bbuff.ReadByte();
                                    string start = bbuff.ReadString();
                                    uint   type  = bbuff.ReadUInt32();
                                    string end   = bbuff.ReadString();

                                    //wanna handle text if prefaced with "-"
                                    //since these are commands to the bot

                                    if (start.StartsWith("--"))
                                    {
                                        forward = false;

                                        start = start.Substring(1, start.Length - 1);

                                        ServerPackets.Send_Text(type, start, end);
                                    }
                                    else if (start.StartsWith("-"))
                                    {
                                        forward = false;

                                        start = start.Substring(1, start.Length - 1);

                                        if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
                                        {
                                            ScriptEvent sc_ev = new ScriptEvent();
                                            sc_ev.Type = EventType.ChatToBot;
                                            sc_ev.Variables.Add(new ScriptVariable((long)type, "MESSAGETYPE", Var_Types.INT, Var_State.PUBLIC));
                                            sc_ev.Variables.Add(new ScriptVariable(end, "TARGETNAME", Var_Types.STRING, Var_State.PUBLIC));
                                            sc_ev.Variables.Add(new ScriptVariable(start, "MESSAGE", Var_Types.STRING, Var_State.PUBLIC));
                                            ScriptEngine.SendToEventQueue(sc_ev);
                                        }
                                    }
                                }
                                break;

                            case PClient.CharacterSelect:
                                if ((!Globals.gamedata.OOG) && (!System.String.IsNullOrEmpty(Globals.SecurityPin)) && (Globals.gamedata.SecurityPinOldClient) && (!Globals.gamedata.SecurityPinSent))
                                {
                                    ServerPackets.RequestSecurityPinWindow();

                                    while (!Globals.gamedata.SecurityPinWindow)
                                    {
                                        System.Threading.Thread.Sleep(100);
                                    }

                                    Globals.l2net_home.Add_Text("Sending security pin: " + Globals.SecurityPin, Globals.Green, TextType.BOT);

                                    ServerPackets.SecurityPin();

                                    while (!Globals.gamedata.SecurityPinOk)
                                    {
                                        System.Threading.Thread.Sleep(100);
                                    }
                                    Globals.l2net_home.Add_Text("Pin OK", Globals.Green, TextType.BOT);
                                    Globals.gamedata.SecurityPinSent = true;
                                }
                                break;
                            }

                            if (forward)
                            {
                                //send packets from the client right to the server
                                bbuffer0 = new ByteBuffer(buffpacketin);

                                Globals.gamedata.SendToGameServerNF(bbuffer0);
                            }
                        }

                        if (cnt > 2)
                        {
                            size = System.BitConverter.ToUInt16(buffread, 0);
                        }
                    }            //end of while loop
                }                //end of while running
            }
            catch (System.Exception e)
            {
                Globals.l2net_home.Add_Error("crash: ClientReadThread : " + e.Message);
                network_exception();
            }
        } //end of read data
Exemplo n.º 51
0
 private void DeleteCharacter(S.DeleteCharacter p)
 {
     DeleteCharacterButton.Enabled = true;
     switch (p.Result)
     {
         case 0:
             MirMessageBox.Show("Deleting characters is currently disabled.");
             break;
         case 1:
             MirMessageBox.Show("The character you selected does not exist.\n Contact a GM for assistance.");
             break;
     }
 }
Exemplo n.º 52
0
 private void button_dead_castle_Click(object sender, System.EventArgs e)
 {
     //return to castle
     ServerPackets.Return(2);
     panel_dead.Hide();
 }
Exemplo n.º 53
0
        private void StartGame(S.StartGameDelay p)
        {
            StartGameButton.Enabled = true;

            long time = CMain.Time + p.Milliseconds;

            MirMessageBox message = new MirMessageBox(string.Format("You cannot log onto this character for another {0} seconds.", Math.Ceiling(p.Milliseconds/1000M)));

            message.BeforeDraw += (o, e) => message.Label.Text = string.Format("You cannot log onto this character for another {0} seconds.", Math.Ceiling((time - CMain.Time)/1000M));
                

            message.AfterDraw += (o, e) =>
            {
                if (CMain.Time <= time) return;
                message.Dispose();
                StartGame();
            };

            message.Show();
        }
Exemplo n.º 54
0
 private void button_dead_siege_Click(object sender, System.EventArgs e)
 {
     //return to siege hq
     ServerPackets.Return(3);
     panel_dead.Hide();
 }
Exemplo n.º 55
0
        public void StartGame(S.StartGame p)
        {
            StartGameButton.Enabled = true;

            if (p.Resolution < Settings.Resolution || Settings.Resolution == 0) Settings.Resolution = p.Resolution;

            if (p.Resolution < 1024 || Settings.Resolution < 1024) Settings.Resolution = 800;
            else if (p.Resolution < 1366 || Settings.Resolution < 1280) Settings.Resolution = 1024;
            else if (p.Resolution < 1366 || Settings.Resolution < 1366) Settings.Resolution = 1280;//not adding an extra setting for 1280 on server cause well it just depends on the aspect ratio of your screen
            else if (p.Resolution >= 1366 && Settings.Resolution >= 1366) Settings.Resolution = 1366;

            switch (p.Result)
            {
                case 0:
                    MirMessageBox.Show("Starting the game is currently disabled.");
                    break;
                case 1:
                    MirMessageBox.Show("You are not logged in.");
                    break;
                case 2:
                    MirMessageBox.Show("Your character could not be found.");
                    break;
                case 3:
                    MirMessageBox.Show("No active map and/or start point found.");
                    break;
                case 4:
                    if (Settings.Resolution == 1024)
                        CMain.SetResolution(1024, 768);
                    else if (Settings.Resolution == 1280)
                        CMain.SetResolution(1280, 800);
                    else if (Settings.Resolution == 1366)
                        CMain.SetResolution(1366, 768);
                    ActiveScene = new GameScene();
                    Dispose();
                    break;
            }
        }
Exemplo n.º 56
0
 /// <summary>Creates a new packet with a given ID. Used for sending.</summary>
 /// <param name="id">The packet ID.</param>
 public Packet(ServerPackets id) : this((int)id)
 {
 }