示例#1
0
        DB Load(string dbPath, string name)
        {
            // Nacitani cesty ke skriptum a dbc souborum
            string filescp = dbPath + "/scripts/" + name; // cesta ke skriptum
            string filedbc = dbPath + "/dbc/" + name;     // cesta k dbc souborum

            DB db;

            // Nacitani SCP souboru

            if (File.Exists(filescp + ".scp"))
            {
                db = new DBMemory(filescp + ".scp", true, new DB.ReadSectionFunction(DB.ConvertType));
                gameServer.LogMessage("Load script " + name + " count=" + db.Count());
                return(db);
            }

            ArrayList a = GetDBCStruct(name);

            if (a.Count == 0)
            {
                return(null);
            }

            // Nacitani DBC souboru
            if (File.Exists(filedbc + ".dbc"))
            {
                db = new DBDBC(filedbc + ".dbc", a);
                gameServer.LogMessage("Load DBC " + name + " count=" + db.Count());
                return(db);
            }

            gameServer.LogMessage("Can't load script or dbc file - filename: " + name);
            return(null);
        }
        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
        }
        void RunMsg(OP code)
        {
            switch (code)
            {
            case OP.CMSG_AUTH_SESSION:                    //   CMSG_AUTH_SESSION
            {
                if (LogMessageEvent != null)
                {
                    LogMessageEvent("CMSG_AUTH_SESSION build=" + inPacket.Seek(2).GetWord());
                }
                Seek(6).Get(out userName);

                pendAuth          = new Hashtable();
                pendAuth["Name"]  = userName;
                pendAuth["Hash"]  = this.GetHashCode();
                pendAuth["Retry"] = (int)0;
                ServerGroup.Send(ServerGroupMessageType.UserQuery, pendAuth);
                SetTimeoutFunction("CMSG_AUTH_SESSION", 500, new TimerFunction(CheckAuth));
            }
            break;

            case OP.CMSG_PING:
                Send(OP.SMSG_PONG, Seek(2).GetArray(4));
                break;

            default:
            {
                DoMessageFunction h = handler[code] as DoMessageFunction;
                if (h == null)
                {
                    gameServer.LogMessage("UNKNOWN OP: ", code.ToString(), (ushort)code, inPacket.Length);
                    Send(OP.MSG_NULL_ACTION, new byte[] { 0, (byte)code, (byte)((ushort)code >> 8) });
                }
                else
                {
                    h(code, this);
                }
                break;
            }
            }
        }
示例#4
0
 uint Get(Hashtable data, string name, uint def)
 {
     try
     {
         if (data.Contains(name))
         {
             return((uint)(int)data[name]);
         }
     }
     catch (FormatException e)
     {
         gameServer.LogMessage("ItemHandler error name:" + name + " error: " + e.Message);
     }
     return(def);
 }