Ejemplo n.º 1
0
        public MapInstance(DBWorldMap map)
        {
            m_map      = map;
            m_bottomX  = map.BottomX;
            m_bottomY  = map.BottomY;
            m_topX     = map.TopX;
            m_topY     = map.TopY;
            m_tileSize = map.TileSize;
            m_columns  = (m_topX - m_bottomX) / m_tileSize;
            m_rows     = (m_topY - m_bottomY) / m_tileSize;
            m_mapTiles = new MapTile[m_columns, m_rows];
            for (int i = 0; i < m_columns; i++)
            {
                for (int j = 0; j < m_rows; j++)
                {
                    int baseX = m_bottomX + i * m_tileSize;
                    int baseY = m_bottomY + j * m_tileSize;
                    m_mapTiles[i, j] = new MapTile(this, baseX, baseY, baseX + m_tileSize, baseY + m_tileSize);
                }
            }
            for (int x = 0; x < m_columns; x++)
            {
                for (int y = 0; y < m_rows; y++)
                {
                    MapTile tile = m_mapTiles[x, y];
                    tile.Adjacents[0] = GetTile(x - 1, y + 1);
                    tile.Adjacents[1] = GetTile(x, y + 1);
                    tile.Adjacents[2] = GetTile(x + 1, y + 1);

                    tile.Adjacents[3] = GetTile(x - 1, y);
                    tile.Adjacents[4] = tile;
                    tile.Adjacents[5] = GetTile(x + 1, y);

                    tile.Adjacents[6] = GetTile(x - 1, y - 1);
                    tile.Adjacents[7] = GetTile(x, y - 1);
                    tile.Adjacents[8] = GetTile(x + 1, y - 1);
                }
            }
            InitSpawns();
        }
Ejemplo n.º 2
0
        internal static void ChangeMap(LoginClient client)
        {
            client.WorldConnection = (WorldConnection)m_worldMapServer[client.Character.WorldMapID];
            if (client.WorldConnection == null)
            {
                client.Close("(ChangeMap) Missing worldserver for world map id " + client.Character.WorldMapID);
                return;
            }

            DBWorldMap map = (DBWorldMap)DataServer.Database.FindObjectByKey(typeof(DBWorldMap), client.Character.WorldMapID);

            client.Character.Continent = (uint)map.Continent;

            BinWriter pkg = LoginClient.NewPacket(SMSG.NEW_WORLD);

            pkg.Write((byte)client.Character.Continent);
            pkg.WriteVector(client.Character.Position);
            pkg.Write(client.Character.Facing);
            client.Send(pkg);
            FriendIsOnline(client);
            client.WorldConnection.OnEnterWorld(client.Character, client.Account.AccessLvl);
        }
Ejemplo n.º 3
0
        static void InitMaps(WORLDMSG msgID, BinReader data)
        {
            int numMaps = data.ReadInt32();

            for (int i = 0; i < numMaps; i++)
            {
                DBWorldMap map       = new DBWorldMap(data);
                int        numSpawns = data.ReadInt32();
                map.Spawns = new DBSpawn[numSpawns];
                for (int j = 0; j < numSpawns; j++)
                {
                    DBSpawn spawn = new DBSpawn();
                    spawn.Deserialize(data);
                    spawn.Creature = (DBCreature)DBManager.GetDBObject(typeof(DBCreature), spawn.CreatureID);
                    if (spawn.Creature == null)
                    {
                        Console.WriteLine("Spawn " + spawn.ObjectId + " is missing creature on worldserver.");
                    }
                    map.Spawns[j] = spawn;
                }
                m_maps[map.ObjectId] = new MapInstance(map);
            }
        }
Ejemplo n.º 4
0
        public static void SetWorldServer(ClientBase worldConnection, uint[] worldMapIDs)
        {
            DBWorldMap[] worldMaps = new DBWorldMap[worldMapIDs.Length];
            for (int i = 0; i < worldMapIDs.Length; i++)
            {
                worldMaps[i] = (DBWorldMap)DataServer.Database.FindObjectByKey(typeof(DBWorldMap), worldMapIDs[i]);
                if (worldMaps[i] == null)
                {
                    throw new Exception("Missing worldmap " + worldMapIDs[i]);
                }
                if (m_worldMapServer.Contains(worldMaps[i].ObjectId))
                {
                    throw new Exception("There's already a worldserver handling worldmap " + worldMaps[i].ObjectId);
                }
            }
            WorldConnection server = new WorldConnection(worldConnection, worldMaps);

            foreach (DBWorldMap map in worldMaps)
            {
                m_worldMapServer[map.ObjectId] = server;
            }
            m_worldServers.Add(server);
        }