/// <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); } }
/// <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); } }
/// <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); }
/// <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); }
/// <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; }
/// <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); }
/// <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); } }
public static bool IsBoatOwner(string playerstrID, GameBoat boat) { if (playerstrID == null || boat == null) { return(false); } if (playerstrID == boat.OwnerID) { return(true); } else { return(false); } }
/// <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; }
/// <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); }
/// <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); }
public static bool IsBoatOwner(string playerstrID, GameBoat boat) { if (playerstrID == null || boat == null) return false; if (playerstrID == boat.OwnerID) return true; else return false; }
/// <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; }
/// <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; } }
/// <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; }