Beispiel #1
0
        /// <summary>
        /// Delete's a boat
        /// </summary>
        /// <returns>true or false</returns>
        public static bool DeleteBoat(string boatName)
        {
            try
            {
                GameBoat removeBoat = GetBoatByName(boatName);
                // Does boat exist, if not return null
                if (removeBoat == null)
                {
                    return(false);
                }

                var boats = GameServer.Database.SelectObjects <DBBoat>("BoatName='" + GameServer.Database.Escape(boatName) + "'");
                foreach (DBBoat boat in boats)
                {
                    GameServer.Database.DeleteObject(boat);
                }

                RemoveBoat(removeBoat);

                return(true);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("DeleteBoat", e);
                }
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Delete's a boat
        /// </summary>
        /// <returns>true or false</returns>
        public static bool DeleteBoat(string boatName)
        {
            try
            {
                GameBoat removeBoat = GetBoatByName(boatName);

                // Does boat exist, if not return null
                if (removeBoat == null)
                {
                    return(false);
                }

                var boats = GameServer.Database.FindObjectByKey <DBBoat>(boatName);
                GameServer.Database.DeleteObject(boats);

                RemoveBoat(removeBoat);

                return(true);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("DeleteBoat", e);
                }

                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Returns a database ID for a matching boat name.
        /// </summary>
        /// <returns>Boat</returns>
        public static string BoatNameToBoatID(string boatName)
        {
            GameBoat b = GetBoatByName(boatName);

            if (b == null)
            {
                return("");
            }
            return(b.BoatID);
        }
Beispiel #4
0
 /// <summary>
 /// Checks if a player can see the boat.
 /// </summary>
 public bool CanSeeBoat(GamePlayer player, GameBoat boat)
 {
     foreach (GamePlayer plr in boat.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
     {
         if (player.Name == plr.Name)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #5
0
        /// <summary>
        /// Removes a player boat from the manager
        /// </summary>
        /// <param name="boat">the boat</param>
        /// <returns></returns>
        public static bool RemoveBoat(GameBoat boat)
        {
            if (boat == null)
                return false;

            lock (m_boats.SyncRoot)
            {
                m_boats.Remove(boat.Name);
                m_boatids.Remove(boat.InternalID);
            }
            return true;
        }
Beispiel #6
0
        /// <summary>
        /// Removes a player boat from the manager
        /// </summary>
        /// <param name="boat">the boat</param>
        /// <returns></returns>
        public static bool RemoveBoat(GameBoat boat)
        {
            if (boat == null)
            {
                return(false);
            }

            lock (m_boats.SyncRoot)
            {
                m_boats.Remove(boat.Name);
                m_boatids.Remove(boat.InternalID);
            }
            return(true);
        }
Beispiel #7
0
        /// <summary>
        /// Creates a new boat
        /// </summary>
        /// <returns>BoatEntry</returns>
        public static GameBoat CreateBoat(GamePlayer creator, GameBoat boat)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("Create boat; boat name=\"" + boat.Name + "\"");
            }

            try
            {
                // Does boat exist, if so return null
                if (DoesBoatExist(boat.Name) == true)
                {
                    if (creator != null)
                    {
                        creator.Out.SendMessage(boat.Name + " already exists!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }

                    return(null);
                }

                // Check if client exists
                if (creator == null)
                {
                    return(null);
                }

                // create table of GameBoat
                boat.theBoatDB                  = new DBBoat();
                boat.theBoatDB.BoatOwner        = creator.InternalID;
                boat.theBoatDB.BoatID           = boat.BoatID;
                boat.theBoatDB.BoatMaxSpeedBase = boat.MaxSpeedBase;
                boat.theBoatDB.BoatModel        = boat.Model;
                boat.theBoatDB.BoatName         = boat.Name;
                boat.OwnerID = creator.InternalID;
                boat.Flags  ^= GameNPC.eFlags.PEACE;

                AddBoat(boat);
                GameServer.Database.AddObject(boat.theBoatDB);
                return(boat);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("CreateBoat", e);
                }

                return(null);
            }
        }
Beispiel #8
0
        public static bool IsBoatOwner(string playerstrID, GameBoat boat)
        {
            if (playerstrID == null || boat == null)
            {
                return(false);
            }

            if (playerstrID == boat.OwnerID)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Adds a player boat to the list of boats
        /// </summary>
        /// <param name="boat">The boat to add</param>
        /// <returns>True if the function succeeded, otherwise false</returns>
        public static bool AddBoat(GameBoat boat)
        {
            if (boat == null)
                return false;

            lock (m_boats.SyncRoot)
            {
                if (!m_boats.Contains(boat.Name))
                {
                    m_boats.Add(boat.Name, boat);
                    m_boatids.Add(boat.BoatID, boat.Name);
                    return true;
                }
            }

            return false;
        }
Beispiel #10
0
        /// <summary>
        /// Adds a player boat to the list of boats
        /// </summary>
        /// <param name="boat">The boat to add</param>
        /// <returns>True if the function succeeded, otherwise false</returns>
        public static bool AddBoat(GameBoat boat)
        {
            if (boat == null)
            {
                return(false);
            }

            lock (m_boats.SyncRoot)
            {
                if (!m_boats.Contains(boat.Name))
                {
                    m_boats.Add(boat.Name, boat);
                    m_boatids.Add(boat.BoatID, boat.Name);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #11
0
        /// <summary>
        /// Load all boats from the database
        /// </summary>
        public static bool LoadAllBoats()
        {
            lock (m_boats.SyncRoot)
            {
                m_boats.Clear();
            }

            //load boats
            var objs = GameServer.Database.SelectAllObjects <DBBoat>();

            foreach (var obj in objs)
            {
                GameBoat myboat = new GameBoat();
                myboat.LoadFromDatabase(obj);
                AddBoat(myboat);
            }

            return(true);
        }
Beispiel #12
0
        public static bool IsBoatOwner(string playerstrID, GameBoat boat)
        {
            if (playerstrID == null || boat == null)
                return false;

            if (playerstrID == boat.OwnerID)
                return true;
            else
                return false;
        }
Beispiel #13
0
        /// <summary>
        /// Load all boats from the database
        /// </summary>
        public static bool LoadAllBoats()
        {
            lock (m_boats.SyncRoot)
            {
                m_boats.Clear();
            }

            //load boats
            var objs = GameServer.Database.SelectAllObjects<DBBoat>();
            foreach (var obj in objs)
            {
                GameBoat myboat = new GameBoat();
                myboat.LoadFromDatabase(obj);
                AddBoat(myboat);
            }

            return true;
        }
Beispiel #14
0
        /// <summary>
        /// Creates a new boat
        /// </summary>
        /// <returns>BoatEntry</returns>
        public static GameBoat CreateBoat(GamePlayer creator, GameBoat boat)
        {
            if (log.IsDebugEnabled)
                log.Debug("Create boat; boat name=\"" + boat.Name + "\"");
            try
            {
                // Does boat exist, if so return null
                if (DoesBoatExist(boat.Name) == true)
                {
                    if (creator != null)
                        creator.Out.SendMessage(boat.Name + " already exists!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return null;
                }

                // Check if client exists
                if (creator == null)
                    return null;


                //create table of GameBoat
                boat.theBoatDB = new DBBoat();
                boat.theBoatDB.BoatOwner = creator.InternalID;
                boat.theBoatDB.BoatID = boat.BoatID;
                boat.theBoatDB.BoatMaxSpeedBase = boat.MaxSpeedBase;
                boat.theBoatDB.BoatModel = boat.Model;
                boat.theBoatDB.BoatName = boat.Name;
                boat.OwnerID = creator.InternalID;
                boat.Flags ^= GameNPC.eFlags.PEACE;

                AddBoat(boat);
                GameServer.Database.AddObject(boat.theBoatDB);
                return boat;
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("CreateBoat", e);
                return null;
            }
        }
Beispiel #15
0
 /// <summary>
 /// Checks if a player can see the boat.
 /// </summary>
 public bool CanSeeBoat(GamePlayer player, GameBoat boat)
 {
     foreach (GamePlayer plr in boat.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
     {
         if (player.Name == plr.Name)
             return true;
     }
     return false;
 }