public override void LoadFromDatabase(DBArea area) { m_translationId = area.TranslationId; m_Description = area.Description; Position = new Vector3(area.X, area.Y, area.Z); m_Radius = area.Radius; m_RadiusRadius = area.Radius * area.Radius; }
public override void LoadFromDatabase(DBArea area) { m_translationId = area.TranslationId; Description = area.Description; X = area.X; Y = area.Y; Radius = area.Radius; StringPoints = area.Points; }
public override void LoadFromDatabase(DBArea area) { m_translationId = area.TranslationId; Description = area.Description; X = area.X; Y = area.Y; Z = area.Z; Radius = area.Radius; m_RadiusRadius = area.Radius * area.Radius; }
public override void LoadFromDatabase(DBArea area) { m_dbArea = area; m_translationId = area.TranslationId; Description = area.Description; X = area.X; Y = area.Y; Width = area.Radius; Height = area.Radius; }
public override void LoadFromDatabase(DBArea area) { base.LoadFromDatabase(area); m_dbBindPoint = new BindPoint(); m_dbBindPoint.Radius = (ushort)area.Radius; m_dbBindPoint.X = area.X; m_dbBindPoint.Y = area.Y; m_dbBindPoint.Z = area.Z; m_dbBindPoint.Region = area.Region; }
public override void LoadFromDatabase(DBArea area) { base.LoadFromDatabase(area); BindPoint = new BindPoint { Radius = (ushort)area.Radius, X = area.X, Y = area.Y, Z = area.Z, Region = area.Region }; }
public void ChangeRadius(int newRadius) { GameServer.KeepManager.Log.Debug("ChangeRadius called for " + Keep.Name + " currently is " + Radius + " changing to " + newRadius); // setting radius to default if (newRadius == 0 && Radius != 0) { if (m_dbArea != null) { GameServer.Database.DeleteObject(m_dbArea); } Radius = Keep is GameKeep ? (Keep.IsPortalKeep ? PK_RADIUS : KEEP_RADIUS) : TOWER_RADIUS; return; } // setting different radius when radius was already something if (newRadius > 0 && Radius >= 0) { Radius = newRadius; if (m_dbArea != null) { m_dbArea.Radius = Radius; GameServer.Database.SaveObject(m_dbArea); } else { m_dbArea = new DBArea(); m_dbArea.CanBroadcast = CanBroadcast; m_dbArea.CheckLOS = CheckLOS; m_dbArea.ClassType = GetType().ToString(); m_dbArea.Description = Description; m_dbArea.Radius = Radius; m_dbArea.Region = (ushort)Keep.Region; m_dbArea.Sound = Sound; m_dbArea.X = X; m_dbArea.Y = Y; m_dbArea.Z = Z; GameServer.Database.AddObject(m_dbArea); } } }
public abstract void LoadFromDatabase(DBArea area);
public override void LoadFromDatabase(DBArea area) { base.LoadFromDatabase(area); GameServer.KeepManager.Log.Debug("KeepArea " + area.Description + " LoadFromDatabase called"); GameServer.KeepManager.Log.Debug("X: " + area.X + "(" + m_X + ") Y: " + area.Y + "(" + m_Y + ") Region:" + area.Region + " Radius: " + m_Radius); }
/// <summary> /// Load from Database override to clone objects from original Region. /// Loads Objects, Mobs, Areas from Database using "SkinID" /// </summary> public override void LoadFromDatabase(Mob[] mobObjs, ref long mobCount, ref long merchantCount, ref long itemCount, ref long bindCount) { if (!LoadObjects) { return; } Assembly gasm = Assembly.GetAssembly(typeof(GameServer)); var staticObjs = GameServer.Database.SelectObjects <WorldObject>("`Region` = @Region", new QueryParameter("@Region", Skin)); var areaObjs = GameServer.Database.SelectObjects <DBArea>("`Region` = @Region", new QueryParameter("@Region", Skin)); int count = mobObjs.Length + staticObjs.Count; if (count > 0) { PreAllocateRegionSpace(count + 100); } int myItemCount = staticObjs.Count; int myMobCount = 0; int myMerchantCount = 0; string allErrors = string.Empty; if (mobObjs.Length > 0) { foreach (Mob mob in mobObjs) { GameNPC myMob = null; string error = string.Empty; // Default Classtype string classtype = ServerProperties.Properties.GAMENPC_DEFAULT_CLASSTYPE; // load template if any INpcTemplate template = null; if (mob.NPCTemplateID != -1) { template = NpcTemplateMgr.GetTemplate(mob.NPCTemplateID); } if (mob.Guild.Length > 0 && mob.Realm >= 0 && mob.Realm <= (int)eRealm._Last) { Type type = ScriptMgr.FindNPCGuildScriptClass(mob.Guild, (eRealm)mob.Realm); if (type != null) { try { myMob = (GameNPC)type.Assembly.CreateInstance(type.FullName); } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("LoadFromDatabase", e); } } } } if (myMob == null) { if (template != null && template.ClassType != null && template.ClassType.Length > 0 && template.ClassType != Mob.DEFAULT_NPC_CLASSTYPE && template.ReplaceMobValues) { classtype = template.ClassType; } else if (!string.IsNullOrWhiteSpace(mob.ClassType) && mob.ClassType != Mob.DEFAULT_NPC_CLASSTYPE) { classtype = mob.ClassType; } try { myMob = (GameNPC)gasm.CreateInstance(classtype, false); } catch { error = classtype; } if (myMob == null) { foreach (Assembly asm in ScriptMgr.Scripts) { try { myMob = (GameNPC)asm.CreateInstance(classtype, false); error = string.Empty; } catch { error = classtype; } if (myMob != null) { break; } } if (myMob == null) { myMob = new GameNPC(); error = classtype; } } } if (!allErrors.Contains(error)) { allErrors += $" {error},"; } if (myMob != null) { try { Mob clone = (Mob)mob.Clone(); clone.AllowAdd = false; clone.AllowDelete = false; clone.Region = ID; myMob.LoadFromDatabase(clone); if (myMob is GameMerchant) { myMerchantCount++; } else { myMobCount++; } } catch (Exception e) { if (log.IsErrorEnabled) { log.Error($"Failed: {myMob.GetType().FullName}:LoadFromDatabase({mob.GetType().FullName});", e); } throw; } myMob.AddToWorld(); } } } if (staticObjs.Count > 0) { foreach (WorldObject item in staticObjs) { WorldObject itemclone = (WorldObject)item.Clone(); itemclone.AllowAdd = false; itemclone.AllowDelete = false; itemclone.Region = ID; GameStaticItem myItem; if (!string.IsNullOrEmpty(itemclone.ClassType)) { myItem = gasm.CreateInstance(itemclone.ClassType, false) as GameStaticItem; if (myItem == null) { foreach (Assembly asm in ScriptMgr.Scripts) { try { myItem = (GameStaticItem)asm.CreateInstance(itemclone.ClassType, false); } catch { } if (myItem != null) { break; } } if (myItem == null) { myItem = new GameStaticItem(); } } } else { myItem = new GameStaticItem(); } myItem.AddToWorld(); } } int areaCnt = 0; // Add missing area foreach (DBArea area in areaObjs) { // Don't bind in instance. if (area.ClassType.Equals("DOL.GS.Area+BindArea")) { continue; } // clone DB object. DBArea newDBArea = (DBArea)area.Clone(); newDBArea.AllowAdd = false; newDBArea.Region = ID; // Instantiate Area with cloned DB object and add to region try { AbstractArea newArea = (AbstractArea)gasm.CreateInstance(newDBArea.ClassType, false); newArea.LoadFromDatabase(newDBArea); newArea.Sound = newDBArea.Sound; newArea.CanBroadcast = newDBArea.CanBroadcast; newArea.CheckLOS = newDBArea.CheckLOS; AddArea(newArea); areaCnt++; } catch { log.Warn($"area type {area.ClassType} cannot be created, skipping"); continue; } } if (myMobCount + myItemCount + myMerchantCount > 0) { if (log.IsInfoEnabled) { log.Info($"AdventureWingInstance: {Description} ({ID}) loaded {myMobCount} mobs, {myMerchantCount} merchants, {myItemCount} items, {areaCnt}/{areaObjs.Count} areas from DB ({TimeManager.Name})"); } log.Debug($"Used Memory: {GC.GetTotalMemory(false) / 1024 / 1024}MB"); if (allErrors != string.Empty) { log.Error($"Error loading the following NPC ClassType(s), GameNPC used instead:{allErrors.TrimEnd(',')}"); } Thread.Sleep(0); // give up remaining thread time to other resources } mobCount += myMobCount; merchantCount += myMerchantCount; itemCount += myItemCount; }
public void OnCommand(GameClient client, string[] args) { if (args.Length == 1) { DisplaySyntax(client); return; } switch (args[1].ToLower()) { #region Create case "create": { if (args.Length != 7) { DisplaySyntax(client); return; } DBArea area = new DBArea(); area.Description = args[2]; switch (args[3].ToLower()) { case "circle": area.ClassType = "DOL.GS.Area+Circle"; break; case "square": area.ClassType = "DOL.GS.Area+Square"; break; case "safe": case "safearea": area.ClassType = "DOL.GS.Area+SafeArea"; break; case "bind": case "bindarea": area.ClassType = "DOL.GS.Area+BindArea"; break; default: { DisplaySyntax(client); return; } } area.Radius = Convert.ToInt16(args[4]); switch (args[5].ToLower()) { case "y": { area.CanBroadcast = true; break; } case "n": { area.CanBroadcast = false; break; } default: { DisplaySyntax(client); return; } } area.Sound = byte.Parse(args[6]); area.Region = client.Player.CurrentRegionID; area.X = client.Player.X; area.Y = client.Player.Y; area.Z = client.Player.Z; Assembly gasm = Assembly.GetAssembly(typeof(GameServer)); AbstractArea newArea = (AbstractArea)gasm.CreateInstance(area.ClassType, false); newArea.LoadFromDatabase(area); newArea.Sound = area.Sound; newArea.CanBroadcast = area.CanBroadcast; WorldMgr.GetRegion(client.Player.CurrentRegionID).AddArea(newArea); GameServer.Database.AddObject(area); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Area.AreaCreated", area.Description, area.X, area.Z, area.Radius, area.CanBroadcast.ToString(), area.Sound)); break; } #endregion Create #region Default default: { DisplaySyntax(client); break; } #endregion Default } }