示例#1
0
        static void OnPlayerEnterWorld(WORLDMSG msgID, BinReader data)
        {
            uint        id          = data.ReadUInt32();
            ACCESSLEVEL accesslevel = (ACCESSLEVEL)data.ReadByte();
            DBCharacter c           = (DBCharacter)DBManager.GetDBObject(typeof(DBCharacter), id);

            if (c == null)
            {
                Console.WriteLine("Failed to enter world with id " + id + ". WorldServer is missing Character object");
                return;
            }
            WorldClient client = new WorldClient(c);
            MapInstance map    = (MapInstance)m_maps[c.WorldMapID];

            if (map == null)
            {
                Console.WriteLine("Worldserver is not handling " + c.WorldMapID + "!");
                client.LeaveWorld();
                return;
            }
            map.SetObjectPositionInBounds(client.Player);
            //client.CreatePlayerObject();
            client.Player.AccessLvl = accesslevel;
            map.Enter(client.Player);
        }
示例#2
0
        public static void ChangeMap(WorldClient client)
        {
            if (client.Player.MapTile == null)
            {
                return;
            }
            MapInstance map = GetMap(client.Player.WorldMapID);

            if (map == null)
            {
                WorldPacket pkg = new WorldPacket(WORLDMSG.CHANGE_MAP);
                pkg.Write(client.CharacterID);
                WorldServer.Send(pkg);
                client.LeaveWorld();
                return;
            }
            else
            {
                client.Player.MapTile.Map.Leave(client.Player);
                client.Player.Continent = (uint)map.Continent;
                map.SetObjectPositionInBounds(client.Player);

                ServerPacket pkg = new ServerPacket(SMSG.NEW_WORLD);
                pkg.Write((byte)client.Player.Continent);
                pkg.WriteVector(client.Player.Position);
                pkg.Write(client.Player.Facing);
                pkg.Finish();
                pkg.AddDestination(client.CharacterID);
                WorldServer.Send(pkg);
            }
        }
示例#3
0
        private static void mainThread()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            try
            {
                m_running = true;
                int shutdownstage = 0;
                while (true)
                {
                    if (!processConnection())
                    {
                        // Todo handle this
                        break;
                    }

                    EventManager.CheckEvents();

                    if (m_shutdown == true)
                    {
                        if (shutdownstage == 0)
                        {
                            // save and remove everything
                            ArrayList   clients = new ArrayList(m_clients.Values);
                            IEnumerator e       = clients.GetEnumerator();
                            while (e.MoveNext())
                            {
                                WorldClient client = (WorldClient)e.Current;
                                client.LeaveWorld();
                            }
                            shutdownstage = 1;
                        }
                        if (shutdownstage == 1 && DBManager.CreateRequestsPending() == 0)
                        {
                            Send(new WorldPacket(WORLDMSG.WORLD_SHUTDOWN));
                            shutdownstage = 2;
                        }
                        if (shutdownstage == 2 && m_connection.PendingSendData == false)
                        {
                            break;
                        }
                    }
                    Thread.Sleep(5);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception e)
            {
                Console.WriteLine("Unhandled worldserver exception!");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                DebugLogger.ILog("", e);
            }
            ObjectManager.CheckBeforeShutdown();
            DBManager.CheckBeforeShutdown();
            m_connection.Close("Server shutting down.");
            m_running = false;
        }
示例#4
0
        static void OnPlayerLeaveWorld(WORLDMSG msgID, BinReader data)
        {
            uint        id     = data.ReadUInt32();
            WorldClient client = WorldServer.GetClientByCharacterID(id);

            if (client == null)
            {
                Console.WriteLine("Failed to leave world. Client didn't exist on worldserver.");
                return;
            }
            client.LeaveWorld();
        }
示例#5
0
 static void OnWorldPortAck(WorldClient client, CMSG msgID, BinReader data)
 {
     if (client.Player.MapTile == null)
     {
         //client.CreatePlayerObject();
         MapInstance map = GetMap(client.Player.WorldMapID);
         if (map == null)
         {
             Console.WriteLine("Error worldserver received MOVE_WORLDPORT_ACK for a worldmap it wasn't handling.");
             client.LeaveWorld();
             return;
         }
         map.Enter(client.Player);
     }
 }