void DoMsgEnum(eWoW.OP code, PlayerConnection conn)
        {
            gameServer.LogMessage("DoMsgEnum OP: " + code);

            ByteArrayBuilder pack = new ByteArrayBuilder(false);

            pack.Add((byte)0);
            string idremove = null;

            foreach (string n in charids)
            {
                Character c = gameServer.LoadCharacter(conn, n);

                if (c == null)
                {
                    idremove = n;
                    continue;
                }

                pack[0]++;

                c.GetEnumData(pack);
            }

            if (idremove != null)
            {
                charids.Remove(idremove);
            }

            //  Odstraneno jelikoz to hazelo chybu error retriving characters.
            //  while(pack.Length <= 159)
            //    pack.Add((uint)0);  // need >= 159*/

            conn.Send(OP.SMSG_CHAR_ENUM, pack);
        }
示例#2
0
        void MessageChat(OP code, PlayerConnection c)
        {
            uint t;
            uint lang;

            c.Seek(2).Get(out t).Get(out lang);

            CHAT mode = (CHAT)t;

            string text   = null;
            string target = null;

            if (mode == CHAT.CHANNEL || mode == CHAT.WHISPER)
            {
                c.Get(out target);
            }
            c.Get(out text);

            if (mode == CHAT.SAY || mode == CHAT.GUILD)
            {
                if (gmcmd.Parse(c.player, text))
                {
                    return;
                }
            }
            c.player.MessageChat(mode, lang, text, target);
        }
示例#3
0
        /*
         * // query packet
         * 79 32 00 00
         * 49 6D 70 20 4D 69 6E 69 6F 6E 00   // name
         * 00
         * 00
         * 00
         * 43 43 43 43 43 43 43 43 43 43 43 43 43 43 00  // guild name
         * 06 00 10 00 // flags1
         * 00 00 00 00
         * 04 00 00 00 // type
         * 02 00 00 00 // unk4
         * 00 00 00 00
         * 00 00 00 00
         *
         * // MSG_CORPSE_QUERY
         * // {01 00 00 00 00 8F 56 D1 44 7B AE D1 44 0A 57 F3 42 00 00 00 00 }
         */

        void CreatureQuery(OP code, PlayerConnection c)
        {
            uint  entry;
            ulong guid;

            c.Seek(2).Get(out entry).Get(out guid);

            Hashtable data = gameServer.DB.creatures.Get("creature " + entry.ToString());

            if (data == null)
            {
                gameServer.LogMessage("CreatureQuery code not found! : " + code + " entry: " + entry + "  guid:" + guid);
                return;
            }
            gameServer.LogMessage("CreatureQuery code: " + code + " entry: " + entry + "  guid:" + guid);

            ByteArrayBuilder pack = new ByteArrayBuilder(false);

            pack.Add(entry);
            pack.Add(data["name"] as string);
            if (data.Contains("name2"))
            {
                pack.Add(data["name2"] as string);
            }
            else
            {
                pack.Add((byte)0);
            }
            if (data.Contains("name3"))
            {
                pack.Add(data["name3"] as string);
            }
            else
            {
                pack.Add((byte)0);
            }
            if (data.Contains("name4"))
            {
                pack.Add(data["name4"] as string);
            }
            else
            {
                pack.Add((byte)0);
            }
            if (data.Contains("guild"))
            {
                pack.Add(data["guild"] as string);
            }
            else
            {
                pack.Add((byte)0);
            }
            pack.Add(Get(data, "flags1", 0));
            pack.Add((uint)0);
            pack.Add(Get(data, "type", 0));
            pack.Add(Get(data, "unk4", 0));
            pack.Add((uint)0);
            pack.Add((uint)0);
            c.Send(OP.SMSG_CREATURE_QUERY_RESPONSE, pack);
        }
示例#4
0
        void MoveChange(OP code, PlayerConnection c)
        {
            uint  flags;
            float u;

            float[] data = new float[4];
            c.Seek(2).
            Get(out flags).Get(out u).Get(out data[0]).
            Get(out data[1]).Get(out data[2]).Get(out data[3]);

            c.player.SetPosition(data);


            // c.Log("{0} {1}", code, c.player.Orientation);

            if (code == OP.MSG_MOVE_HEARTBEAT)
            {
                return;
            }

            ByteArrayBuilder pack = new ByteArrayBuilder(false);

            pack.Add(c.player.GUID);
            pack.Add(flags);
            pack.Add(u);
            pack.Add(data);
            c.player.SendMessageToSet(code, pack, false);
        }
示例#5
0
 public MovementHandler(PlayerConnection c)
 {
     c.AddHandler(OP.CMSG_STANDSTATECHANGE, new DoMessageFunction(StandStateChange), c.player);
     c.AddHandler(OP.CMSG_SETSHEATHED, new DoMessageFunction(SheatheTypeChange), c.player);
     c.AddHandler(OP.MSG_MOVE_JUMP, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_FORWARD, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_BACKWARD, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_SET_FACING, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_STOP, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_STRAFE_LEFT, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_STRAFE_RIGHT, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_STOP_STRAFE, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_TURN_LEFT, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_TURN_RIGHT, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_STOP_TURN, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_PITCH_UP, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_PITCH_DOWN, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_STOP_PITCH, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_SET_RUN_MODE, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_SET_WALK_MODE, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_SET_PITCH, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_START_SWIM, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_STOP_SWIM, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_HEARTBEAT, new DoMessageFunction(MoveChange), c.player);
     c.AddHandler(OP.MSG_MOVE_FALL_LAND, new DoMessageFunction(MoveChange), c.player);
 }
示例#6
0
 public ItemHandler(PlayerConnection c)
 {
     c.AddHandler(OP.CMSG_SWAP_INV_ITEM, new DoMessageFunction(SwapInv), c.player);
     c.AddHandler(OP.CMSG_SWAP_ITEM, new DoMessageFunction(Swap), c.player);
     c.AddHandler(OP.CMSG_DESTROYITEM, new DoMessageFunction(Destroy), c.player);
     c.AddHandler(OP.CMSG_AUTOEQUIP_ITEM, new DoMessageFunction(AutoEquip), c.player);
     c.AddHandler(OP.CMSG_AUTOSTORE_BAG_ITEM, new DoMessageFunction(AutoStoreBag), c.player);
 }
示例#7
0
        void TimeQuery(OP code, PlayerConnection c)
        {
            //gameServer.LogMessage("TimeQuery: code: " + code);
            ByteArrayBuilder b = new ByteArrayBuilder(false);

            b.Add(Const.GetTimeStamp());
            c.Send(OP.SMSG_QUERY_TIME_RESPONSE, b);
        }
示例#8
0
        public override void RunRecv()
        {
            PlayerConnection p = new PlayerConnection(this, sock.Accept());

            p.LogMessageEvent += new eWoW.PlayerConnection.LogMessageHandler(p_LogMessageEvent);
            NetWork.Add(p);
            clients.Add(p);
        }
示例#9
0
        public void Login(PlayerConnection c)
        {
            conn        = c;
            conn.player = this;

            SetMessageHandler();

            Send(OP.SMSG_ACCOUNT_DATA_MD5, new byte[80]);

            ByteArrayBuilder pack = new ByteArrayBuilder(false);

            pack.Add(Pos.x);
            pack.Add(Pos.y);
            pack.Add(Pos.z);
            pack.Add((uint)Zone);
            pack.Add((uint)Map);
            Send(OP.SMSG_BINDPOINTUPDATE, pack);
            pack.Length = 0;

            Send(OP.SMSG_TUTORIAL_FLAGS, tutorialFlags);

            BuildSpellData(pack);
            Send(OP.SMSG_INITIAL_SPELLS, pack);
            pack.Length = 0;

            Send(OP.SMSG_ACTION_BUTTONS, new byte[480]);

            pack.Add((uint)64);
            for (int i = 0; i < 64; i++)
            {
                if (i == 0)
                {
                    pack.Add((uint)3);
                }
                else
                {
                    pack.Add((uint)1);
                }
                pack.Add((byte)0);
            }
            Send(OP.SMSG_INITIALIZE_FACTIONS, pack);
            pack.Length = 0;

            pack.Add(Const.GetTimeStamp());
            pack.Add(0.017f);
            Send(OP.SMSG_LOGIN_SETTIMESPEED, pack);
            pack.Length = 0;

            // clear all items update flag
            BuildUpdateForSet();
            updatePacket.Clear();

            BuildCreateMask(updateMask, true);
            SendUpdate(BuildUpdate(updateMask, UpdateType.All, true));
            SendCreateItems(this, CreateItemType.Self);
            SendUpdate();
            tickRemove = 0;
        }
示例#10
0
        void DoLogoutRequest(OP code, PlayerConnection c)
        {
            gameServer.LogMessage("LogoutRequest name: " + Name + " code: " + code);
            Send(OP.SMSG_LOGOUT_RESPONSE, new byte[5]);

            // need sit
            SetUpdateValue(UpdateFields.UNIT_NPC_EMOTESTATE, (uint)UnitStandState.SITTING);
            c.SetTimeoutFunction("DoLogoutRequest", 0 * 1000, new TimerFunction(LogoutTimeOK)); // Cislo predkrat urcuje za kolik sekund se odhlasi
        }
示例#11
0
        void DoLogoutCancel(OP code, PlayerConnection c)
        {
            gameServer.LogMessage("LogoutCancel name: " + Name + " code:" + code);

            SetUpdateValue(UpdateFields.UNIT_NPC_EMOTESTATE, (uint)UnitStandState.STANDING);

            Send(OP.SMSG_LOGOUT_CANCEL_ACK, new byte[0]);
            c.DeleteTimer("DoLogoutRequest");
        }
示例#12
0
        void SwapInv(OP code, PlayerConnection c)
        {
            byte srcSlot, destSlot;

            c.Seek(2).Get(out srcSlot).Get(out destSlot);

            c.Log("{0} {1} -> {2}", code, srcSlot, destSlot);
            c.player.SwapItem(SlotID.CHARACTER, (SlotID)srcSlot, SlotID.CHARACTER, (SlotID)destSlot);
        }
        void DoMsgCreate(eWoW.OP code, PlayerConnection conn)
        {
            if (charids.Count >= 10)
            {
                conn.Send(OP.SMSG_CHAR_CREATE, new byte[] { (byte)CHAR.CREATE_MAX_PLAYER_REALM });
                return;
            }

            string name;

            conn.Seek(2).Get(out name);

            if (gameServer.GetCharacter(name) != 0)
            {
                gameServer.LogMessage("Create character error nametaken:" + conn.userName + " name: " + name);
                conn.Send(OP.SMSG_CHAR_CREATE, new byte[] { (byte)CHAR.CREATE_NAME_IN_USE });
                return;
            }

            Character c = new Character(gameServer);

            if (!c.CreateNew(conn, name))
            {
                conn.Send(OP.SMSG_CHAR_CREATE, new byte[] { (byte)CHAR.CREATE_FAILED });
                return;
            }

            if (gameServer.Type.ToLower() == "pvp")
            {
                int side = Side(c.Race);
                foreach (string id in charids)
                {
                    Character nc = gameServer.LoadCharacter(conn, id);
                    if (nc != null && Side(nc.Race) != side)
                    {
                        gameServer.DelCharacter(c);
                        gameServer.LogMessage("CMSG_CHAR_CREATE NotSameSide" + conn.userName + " name: " + name);
                        conn.Send(OP.SMSG_CHAR_CREATE, new byte[] { (byte)CHAR.CREATE_NOT_SAME_SIDE });
                        return;
                    }
                }
            }
            gameServer.AddCharacter(name, c.GUID, (byte)c.Race, (byte)c.Gender, (byte)c.Class);
            gameServer.AddObj(c);

            charids.Add(name);
            string str = "";

            foreach (string n in charids)
            {
                str += n + " ";
            }
            gameServer.SetChar(conn.userName, str.Trim());

            conn.Send(OP.SMSG_CHAR_CREATE, new byte[] { (byte)CHAR.CREATE_OK }); // create ok
        }
示例#14
0
 void DoUpdateAccountData(OP code, PlayerConnection c)
 {
     /* Must "translate" from Wowdaemon
      *
      * if(client.Character == null)
      *      return true;
      * uint type = data.ReadUInt32();
      * int len = data.ReadInt32();
      * string conf = string.Empty;
      * if(len > 0)
      * {
      *      try
      *      {
      *              byte[] compressed = data.ReadBytes((int)(data.BaseStream.Length-data.BaseStream.Position));
      *              Inflater inflater = new Inflater();
      *              inflater.SetInput(compressed);
      *              byte[] decompressed = new byte[len];
      *              inflater.Inflate(decompressed);
      *              conf = System.Text.ASCIIEncoding.ASCII.GetString(decompressed);
      *      }
      *      catch(Exception e)
      *      {
      *              Console.WriteLine("Failed to decompress config type " + type + ": " + e.Message);
      *              return true;
      *      }
      * }
      * switch(type)
      * {
      *      case 0:
      *              client.Character.UIConfig0 = conf;
      *              client.Character.Dirty = true;
      *              break;
      *      case 1:
      *              client.Character.UIConfig1 = conf;
      *              client.Character.Dirty = true;
      *              break;
      *      case 2:
      *              client.Character.UIConfig2 = conf;
      *              client.Character.Dirty = true;
      *              break;
      *      case 3:
      *              client.Character.UIConfig3 = conf;
      *              client.Character.Dirty = true;
      *              break;
      *      case 4:
      *              client.Character.UIConfig4 = conf;
      *              client.Character.Dirty = true;
      *              break;
      *      default:
      *              Console.WriteLine("Unknown config type: " + type);
      *              Console.WriteLine(conf);
      *              return true;
      * }
      * DataServer.Database.SaveObject(client.Character);
      * return true;*/
 }
示例#15
0
        void Swap(OP code, PlayerConnection c)
        {
            byte srcBag, srcSlot, destBag, destSlot;

            c.Seek(2).Get(out destBag).Get(out destSlot).Get(out srcBag).Get(out srcSlot);

            c.Log("{0} {1}.{2} -> {3}.{4}", code, srcBag, srcSlot, destBag, destSlot);

            c.player.SwapItem((SlotID)srcBag, (SlotID)srcSlot, (SlotID)destBag, (SlotID)destSlot);
        }
示例#16
0
 void DoLogoutConfirm(OP code, PlayerConnection c)
 {
     // a player wants to leave so his data needs to be saved and the game needs to quit.
     //  (Character) c.player
     gameServer.LogMessage("LogoutConfirm name: " + Name + " code: " + code);
     gameServer.Channel.Logout(Conn);
     Send(OP.SMSG_LOGOUT_COMPLETE, new byte[0]);
     tickRemove = Const.Tick + 3 * 1000;
     c.RemoveHandler(this);
 }
示例#17
0
        void AutoEquip(OP code, PlayerConnection c)
        {
            byte srcBag, srcSlot;

            c.Seek(2).Get(out srcBag).Get(out srcSlot);

            c.Log("{0} {1}.{2}", code, srcBag, srcSlot);

            c.player.AutoEquipItem((SlotID)srcBag, (SlotID)srcSlot);
        }
示例#18
0
        void AutoStoreBag(OP code, PlayerConnection c)
        {
            byte srcBag, srcSlot, destBag;

            c.Seek(2).Get(out srcBag).Get(out srcSlot).Get(out destBag);

            c.Log("{0} {1}.{2} -> {3}", code, srcBag, srcSlot, destBag);

            c.player.SwapItem((SlotID)srcBag, (SlotID)srcSlot, (SlotID)destBag, SlotID.CHARACTER);
        }
示例#19
0
        public Character LoadCharacter(PlayerConnection conn, string name)
        {
            ulong guid = GetCharacter(name);

            if (guid == 0)
            {
                return(null);
            }
            return(LoadCharacter(conn, guid));
        }
示例#20
0
 public void Logout(PlayerConnection c)
 {
     foreach (string chnl in chnls.Keys)
     {
         ArrayList pchnl = chnls[chnl] as ArrayList;
         if (pchnl.Contains(c))
         {
             pchnl.Remove(c);
             ChannelNotify(c, chnl, 3, 0);                     // leave
         }
     }
 }
示例#21
0
        public QueryHandler(GameServer gs, PlayerConnection c)
        {
            gameServer = gs;
            c.AddHandler(OP.CMSG_NAME_QUERY, new DoMessageFunction(NameQuery), c.player);
            c.AddHandler(OP.CMSG_MEETING_STONE_INFO, new DoMessageFunction(MeetingStoneQuery), c.player);
            c.AddHandler(OP.CMSG_GMTICKET_GETTICKET, new DoMessageFunction(GMTicketQuery), c.player);
            c.AddHandler(OP.CMSG_QUERY_TIME, new DoMessageFunction(TimeQuery), c.player);
            c.AddHandler(OP.MSG_QUERY_NEXT_MAIL_TIME, new DoMessageFunction(NextMailTimeQuery), c.player);

            c.AddHandler(OP.CMSG_ITEM_QUERY_SINGLE, new DoMessageFunction(QuerySingle), c.player);
            c.AddHandler(OP.CMSG_CREATURE_QUERY, new DoMessageFunction(CreatureQuery), c.player);
            // c.AddHandler( OP.MSG_CORPSE_QUERY, new DoMessageFunction( CorpseQuery ), c.player);
        }
示例#22
0
        void SheatheTypeChange(OP code, PlayerConnection c)
        {
            uint anim;

            c.Seek(2).Get(out anim);
            c.Log("{0} {1}", code, (SheatheType)anim);

            uint n = c.player.GetUpdateValue(UpdateFields.UNIT_FIELD_BYTES_1);

            n = (uint)((n & 0xffff00ff) | (anim << 8));

            c.player.SetUpdateValue(UpdateFields.UNIT_FIELD_BYTES_1, n);
        }
示例#23
0
 void DoSetSelection(OP code, PlayerConnection c)
 {
     if (code == OP.CMSG_SET_TARGET)
     {
         c.Seek(2).Get(out curTarget);
         // this.SetUpdateValue( UpdateFields.UNIT_FIELD_TARGET, curTarget);
         return;
     }
     if (code == OP.CMSG_SET_SELECTION)
     {
         c.Seek(2).Get(out curSelection);
         gameServer.LogMessage("DoSetSelection code: " + code + " selection: " + curSelection);
     }
 }
示例#24
0
        void StandStateChange(OP code, PlayerConnection c)
        {
            uint anim;

            c.Seek(2).Get(out anim);
            c.Log("{0} {1}", code, (UnitStandState)anim);

            if ((UnitStandState)anim != UnitStandState.SITTING)
            {
                c.player.LogoutCancel();
            }

            c.player.SetUpdateValue(UpdateFields.UNIT_NPC_EMOTESTATE, (uint)anim);
        }
示例#25
0
        void Leave(OP code, PlayerConnection c)
        {
            string chnl;

            c.Seek(2).Get(out chnl);

            ArrayList pchnl = GetChannel(chnl);

            if (pchnl.Contains(c))
            {
                pchnl.Remove(c);
                ChannelNotify(c, chnl, 3, 0);                 // leave
            }
        }
示例#26
0
        void ChannelNotify(PlayerConnection c, string chnl, byte type, uint data)
        {
            ByteArrayBuilder pack = new ByteArrayBuilder();

            pack.Add(type);
            pack.Add(chnl);
            if (type == 2)
            {
                pack.Add(data);
            }


            c.Send(OP.SMSG_CHANNEL_NOTIFY, pack);
        }
示例#27
0
        public override void Regen()
        {
            if (tickRemove > 0 && tickRemove < Const.Tick)         // should exit world
            {
                if (conn != null)
                {
                    conn.player = null;                      // logout
                    conn        = null;
                    gameServer.SaveCharacter(Name, GetSaveData());
                }
                gameServer.DelObj(this);
                return;
            }

            base.Regen();
        }
        void DoMsgDelete(eWoW.OP code, PlayerConnection conn)
        {
            ulong guid;

            conn.Seek(2).Get(out guid);
            gameServer.LogMessage("OP: " + code + "GUID: " + guid);

            Character c = gameServer.LoadCharacter(conn, guid);

            if (c != null)
            {
                gameServer.DelCharacter(c);
                charids.Remove(c.Name);
                gameServer.DelObj(c);
            }
            conn.Send(OP.SMSG_CHAR_DELETE, new byte[] { (byte)CHAR.DELETE_OK });
        }
        public CharacterHandler(GameServer gs, PlayerConnection c, string chars)
        {
            gameServer = gs;
            if (chars != null)
            {
                string[] schars = chars.Split(' ');
                foreach (string s in schars)
                {
                    charids.Add(s);
                }
            }

            c.AddHandler(OP.CMSG_CHAR_CREATE, new DoMessageFunction(DoMsgCreate), this);
            c.AddHandler(OP.CMSG_CHAR_ENUM, new DoMessageFunction(DoMsgEnum), this);
            c.AddHandler(OP.CMSG_CHAR_DELETE, new DoMessageFunction(DoMsgDelete), this);
            c.AddHandler(OP.CMSG_PLAYER_LOGIN, new DoMessageFunction(DoMsgLogin), this);
        }
示例#30
0
        void Join(OP code, PlayerConnection c)
        {
            string chnl;

            c.Seek(2).Get(out chnl);

            ArrayList pchnl = GetChannel(chnl);

            if (pchnl.Contains(c))
            {
                ChannelNotify(c, chnl, 3, 1);
            }
            else
            {
                pchnl.Add(c);
                ChannelNotify(c, chnl, 2, 1);                  // join
            }
        }