public void UnequipItem(CharacterItemRecord item, byte newposition, ItemRecord template, uint quantity) { var existing = Items.ExistingItem(item); if (existing == null) { item.Position = newposition; SaveTask.UpdateElement(item); ItemEffectsProvider.RemoveEffects(Character.Client, item.GetEffects()); RemoveItemSkin(item, template); } else { if (item.UID != existing.UID) { existing.Quantity += quantity; RemoveItem(item.UID, item.Quantity); ItemEffectsProvider.RemoveEffects(Character.Client, item.GetEffects()); RemoveItemSkin(item, template); } else { Character.NotificationError("Spamming ItemMove!"); } } Character.RefreshGroupInformations(); }
public void RemoveItemFromPanel(BankItemRecord obj, int quantity) { if (obj.IsNull()) { return; } if (obj.Quantity == (uint)-quantity) { SaveTask.RemoveElement(obj); var existing = Client.Character.Inventory.Items.ExistingItem(obj); if (existing != null) { existing.Quantity += (uint)-quantity; SaveTask.UpdateElement(existing); Client.Character.Inventory.Refresh(); } else { Client.Character.Inventory.Add(obj); } Client.Send(new StorageObjectRemoveMessage(obj.UID)); } else { obj.Quantity = (uint)(obj.Quantity + quantity); SaveTask.UpdateElement(obj); Client.Character.Inventory.Add(obj, (uint)-quantity); Client.Send(new StorageObjectUpdateMessage(obj.GetObjectItem())); } }
public void RemoveItem(uint id, uint quantity, bool refresh = true) { var item = GetItem(id); if (item == null) { Character.NotificationError("Impossible de retirer l'item, il n'éxiste pas..."); return; } if (quantity == item.Quantity) { Items.Remove(item); SaveTask.RemoveElement(item); CharacterItemRecord.CharactersItems.Remove(item); Character.Client.Send(new ObjectDeletedMessage(item.UID)); } else if (quantity < item.Quantity) { item.Quantity -= (uint)quantity; SaveTask.UpdateElement(item); } if (refresh) { Refresh(); } Character.RefreshShortcuts(); }
public void AddItem(uint uid, int quantity, uint price) { var item = Client.Character.Inventory.GetItem(uid); if (item == null) { Client.Character.ReplyError("Impossible, cet item n'éxiste pas"); return; } if (item.Quantity < quantity) { return; } if (CharacterBidItems.Count == BidShopRecord.GetBidShop(BidShopId).MaxItemPerAccount) { return; } Client.Character.Inventory.RemoveItem(item.UID, (uint)quantity); var existing = CharacterBidItems.Find(x => x.objectUID == item.UID); if (existing == null) { SaveTask.AddElement(new BidShopItemRecord(BidShopId, price, quantity, item)); } else { SaveTask.AddElement(new BidShopItemRecord(BidShopId, price, quantity, item.CloneAndGetNewUID())); } OpenSellPanel(); }
public void AddJobXp(sbyte jobid, ulong amount) { var job = CharacterJobRecord.GetJob(Id, jobid); if (job.JobLevel == 200) { return; } var exp = ExperienceRecord.GetExperienceForLevel((uint)(job.JobLevel + 1)); if (job.JobExp + amount >= exp) { job.JobLevel++; Client.Send(new JobLevelUpMessage(job.JobLevel, job.GetJobDescription())); if (job.JobLevel == 200) { job.JobExp = exp; RefreshJobs(); return; } AddJobXp(jobid, amount); } else { job.JobExp += amount; } SaveTask.UpdateElement(job); RefreshJobs(); }
public void ChangeParameters(WorldClient changer, ushort rank, sbyte experienceGivenPercent, uint rights) { GuildRecord guild = changer.Character.GetGuild(); if (guild == null || guild.Id != this.GuildId) { return; } CharacterGuildRecord modifier = CharacterGuildRecord.GetCharacterGuild(changer.Character.Id); if (modifier != this) { if (modifier.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_XP_CONTRIBUTION)) { this.ExperienceGivenPercent = experienceGivenPercent; } } else { if (this.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_MY_XP_CONTRIBUTION)) { this.ExperienceGivenPercent = experienceGivenPercent; } } if (modifier.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_RANKS)) { this.Rank = rank; } if (modifier.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_RIGHTS)) { this.Rights = rights; } SaveTask.UpdateElement(modifier); }
public void Dispose() { if (Map != null) { Map.Instance.RemoveClient(Client); } if (SearchingArena) { ArenaProvider.Instance.OnClientDisconnected(Client); } if (IsFighting) { FighterInstance.OnDisconnect(); } if (PlayerTradeInstance != null) { PlayerTradeInstance.Abort(); } if (PartyMember != null) { PartyMember.Party.QuitParty(Client); } if (DungeonPartyProvider.Instance.GetDPCByCharacterId(this.Id) != null) { DungeonPartyProvider.Instance.RemoveCharacter(this); } Client.Character.Look.UnsetAura(); Record.Look = Look.ConvertToString(); SaveTask.UpdateElement(Record); SaveTask.UpdateElement(StatsRecord); Inventory.InitializeForSaveTask(); }
public void AddNewTask1() { TaskElement("Maintenance Spend - WTD").Clicks(); RemoveTask.WaitUntil(); RemoveTask.Clicks(); AddBtn.Clicks(); AddNewTask.Clicks(); TaskName.WaitUntil(); TaskName.EnterText("Test Task 1"); TaskTypeParent("Office Tasks").Clicks(); TaskTypeChild("Discipline").Clicks(); WaitforIt(Properties.VeryInactivePhase); Complexity.SelectIndex(1); WaitforIt(Properties.VeryInactivePhase); SaveTask.WaitUntil(); SaveTask.Clicks(); AddBtn.WaitUntil(); }
internal static void Shutdown() { SaveTask.Save(); Logger.Init("Server is now shutting down..."); Thread.Sleep(4000); Environment.Exit(0); }
public void AddNewTask2() { WaitforIt(Properties.InactivePhase); AddBtn.WaitUntil(); AddBtn.Clicks(); AddNewTask.Clicks(); TaskName.WaitUntil(); TaskName.EnterText("Test Task 2"); TaskTypeParent("Office Tasks").Clicks(); TaskTypeChild("Discipline").Clicks(); WaitforIt(Properties.VeryInactivePhase);//WaitforIt(Properties.VeryInactivePhase) Complexity.SelectIndex(1); WaitforIt(Properties.VeryInactivePhase); SaveTask.WaitUntil(); SaveTask.Clicks(); AddBtn.WaitUntil(); }
public void AddNewTask4() { AddBtn.WaitUntil(); AddBtn.Clicks(); AddNewTask.Clicks(); TaskName.WaitUntil(); TaskName.EnterText("Unplanned Task 2"); TaskTypeParent("Office Tasks").Clicks(); TaskTypeChild("Discipline").Clicks(); WaitforIt(Properties.VeryInactivePhase); Complexity.SelectIndex(1); WaitforIt(Properties.InactivePhase); UCodeNewTask.WaitUntil(); UCodeNewTask.Clicks(); WaitforIt(Properties.VeryInactivePhase); UCommentNewTask.EnterText("Unplanned2"); WaitforIt(Properties.InactivePhase); SaveTask.WaitUntil(); SaveTask.Clicks(); WaitforIt(Properties.InactivePhase); AddBtn.WaitUntil(); }
public static void SwapSortcut(int characterid, sbyte firstslot, sbyte secondslot) { var shortcut1 = GetShorcut(characterid, firstslot); var shortcut2 = GetShorcut(characterid, secondslot); if (!shortcut1.IsNull() && !shortcut2.IsNull()) { if (shortcut1.SlotId == firstslot) { shortcut1.SlotId = secondslot; } else { shortcut1.SlotId = firstslot; } if (shortcut2.SlotId == firstslot) { shortcut2.SlotId = secondslot; } else { shortcut2.SlotId = firstslot; } SaveTask.UpdateElement(shortcut2); } else if (shortcut1 != null) { shortcut1.SlotId = secondslot; } SaveTask.UpdateElement(shortcut1); }
public static void Test(string input) { int minuteDelay = 10; WorldServer.Instance.OnClients(x => x.Character.Notification("Pour des raisons de maintenance, le serveur va être redémarré dans " + minuteDelay + " minutes. Merci de votre compréhension.")); ActionTimer action = new ActionTimer((minuteDelay * 60000) / 2, new Action(() => { WorldServer.Instance.OnClients(x => x.Character.Notification("Pour des raisons de maintenance, le serveur va être redémarré dans " + minuteDelay / 2 + " minutes. Merci de votre compréhension.")); }), false); action.Start(); action = new ActionTimer(minuteDelay * 60000, new Action(() => { SaveTask.Save(); Environment.Exit(0); }), false); action.Start(); }
/// <summary> /// 创建一个删除操作 /// </summary> /// <param name="target"></param> /// <returns></returns> public static SaveTask CreateDeleteTask(IStorageTarget target) { SaveTask saveTask = new SaveTask(); saveTask.type = TaskType.DELETE; saveTask.target = target; return(saveTask); }
private void EnqueueTask(SaveTask task) { lock (_saveLock) { _saveQueue.Enqueue(task); } _wh.Set(); }
public void OnConnectionToAuthLost() { logger.Error("Connection to AuthServer was lost.. Server is shutting down."); SaveTask.Save(); WorldServer.Instance.DisconnectAll(); Thread.Sleep(3000); Environment.Exit(0); }
public void MoveItem(uint uid, int quantity) { var item = CharacterBidItems.Find(x => x.objectUID == uid); var realItem = BidShopItemRecord.GetBidShopItem(uid); SaveTask.RemoveElement(realItem); Client.Character.Inventory.Add(new CharacterItemRecord(realItem.UID, 63, realItem.GID, Client.Character.Id, realItem.Quantity, realItem.GetEffects())); OpenSellPanel(); }
/// <summary> /// 创建一个加载操作 /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> public static SaveTask CreateLoadTask(IStorageSource source, IStorageTarget target) { SaveTask saveTask = new SaveTask(); saveTask.type = TaskType.LOAD; saveTask.source = source; saveTask.target = target; return(saveTask); }
/// <summary> /// 创建一个保存操作 /// </summary> /// <param name="target"></param> /// <param name="data"></param> /// <returns></returns> public static SaveTask CreateSaveTask(IStorageTarget target, byte[] data) { SaveTask saveTask = new SaveTask(); saveTask.type = TaskType.SAVE; saveTask.target = target; saveTask.data = data; return(saveTask); }
public ItemCut(CharacterItemRecord item, uint quantity, byte newItempos) { newItem = item.CloneAndGetNewUID(); item.Position = newItempos; item.Quantity = quantity; newItem.Quantity -= quantity; BaseItem = item; SaveTask.UpdateElement(BaseItem); }
public static void AddShortcut(int characterid, sbyte slotid, ushort spellid) { var existing = GetShorcut(characterid, slotid); if (existing != null) { RemoveShortcut(existing.CharacterId, existing.SlotId); } SaveTask.AddElement(new SpellShortcutRecord(SpellsShortcuts.PopNextId <SpellShortcutRecord>(x => x.Id), characterid, spellid, slotid)); }
public static void AddShortcut(int characterid, sbyte slotid, int shortcuttype, int value1, int value2) { var existing = GetShorcut(characterid, slotid); if (existing != null) { RemoveShortcut(existing.CharacterId, existing.SlotId); } SaveTask.AddElement(new GeneralShortcutRecord(GeneralShortcuts.PopNextId <GeneralShortcutRecord>(x => x.Id) , characterid, shortcuttype, value1, value2, slotid)); }
/// <summary> /// Total Initiative = ( Bonus Caractéristiques + Bonus initiative) x ( Points de vie actuels / Points de vie max ) /// </summary> /// <param name="character"></param> public static void Create(Character character) { var breed = BreedRecord.GetBreed(character.Record.Breed); character.Record.SpellPoints = (ushort)ConfigurationManager.Instance.StartLevel; character.Record.StatsPoints = 0; var stats = new StatsRecord(character.Id, breed.StartLifePoints, (short)(ConfigurationManager.Instance.StartLevel * 10), breed.StartLifePoints, breed.StartProspecting, 6, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); character.CurrentStats = new BasicStats((ushort)stats.MaxEnergyPoints, (uint)stats.LifePoints); SaveTask.AddElement(stats); }
public static void AddInstantElements(this IEnumerable <ITable> tables, Type type, bool addtoList = true) { DatabaseManager.GetInstance().WriterInstance(type, DatabaseAction.Add, tables.ToArray()); if (addtoList) { foreach (var table in tables) { SaveTask.AddToList(table); } } }
public static void RemoveInstantElements(this IEnumerable <ITable> tables, Type type, bool removefromList = true) { DatabaseManager.GetInstance().WriterInstance(type, DatabaseAction.Remove, tables.ToArray()); if (removefromList) { foreach (var table in tables) { SaveTask.RemoveFromList(table); } } }
public static void BeforeSave() { var online = WorldServer.Instance.GetAllClientsOnline(); foreach (var client in online) { client.Character.Look.UnsetAura(); client.Character.Record.Look = client.Character.Look.ConvertToString(); SaveTask.UpdateElement(client.Character.Record); SaveTask.UpdateElement(client.Character.StatsRecord); } }
public static void RemoveInstantElement <T>(this T table, bool removefromList = true) where T : ITable { lock (Locker) { DatabaseWriter <T> .InstantRemove(table); if (removefromList) { SaveTask.RemoveFromList(table); } } }
public static void AddInstantElement <T>(this T table, bool addtolist = true) where T : ITable { lock (Locker) { DatabaseWriter <T> .InstantInsert(table); if (addtolist) { SaveTask.AddToList(table); } } }
public static void Stop(string input) { WorldServer.Instance.SetServerStatus(ServerStatusEnum.STOPING); logger.Gray("Server now Offline"); foreach (WorldClient client in WorldServer.Instance.GetOnlineClients()) { client.Disconnect(); } logger.Gray("Each client disconnected"); SaveTask.Save(); logger.Gray("Server Saved"); logger.Gray("You can now quit the application"); }
static void Init() { try { SaveTask.OnSaveStarted += Cache_OnSaveStarted; SaveTask.OnSaveEnded += Cache_OnSaveEnded; SaveTask.Initialize(WorldConfiguration.Instance.SaveInterval); DatabaseBackupProvider.Initialize(Environment.CurrentDirectory + "\\Backups\\"); InitializeSave(); } catch (Exception ex) { logger.Error(ex); } }
// public static void TestInventory(){ // inventory.Add(new Item("Toy")); // inventory.Add(new Item("Toy")); // inventory.Add(new Item("Toy")); // } public static void Save(){ /***** Monster */ // TODO: set properties saveData.monster.prop = GameData.activeMonster.prop; SaveMonster savemon = new SaveMonster(); if(!activeMonster.hatched){ savemon.hatchTimeLeft = (int)activeMonster.hatchTime; } savemon.name = activeMonster.name; savemon.hatched = activeMonster.hatched; savemon.birthday = activeMonster.birthday; savemon.hunger = activeMonster.hunger; savemon.care = activeMonster.care; if(activeMonster.monsterController != null){ Vector3 mpos = activeMonster.position; savemon.x = mpos.x; savemon.y = mpos.y; savemon.z = mpos.z; } saveData.monster = savemon; /***** Items */ List<SaveItem> saveItems = new List<SaveItem>(); foreach(Item item in items){ SaveItem si = new SaveItem(); Vector3 pos = item.position; si.x = pos.x; si.y = pos.y; si.z = pos.z; si.type = (int)item.type; si.foodType = item.foodType; saveItems.Add (si); } saveData.items = saveItems; /***** Tasks */ List<SaveTask> saveTasks = new List<SaveTask>(); foreach(Task t in tasks){ SaveTask st = new SaveTask(t.name, t.id); st.difficulty = t.difficulty; foreach(Task subt in t.subtasks){ SaveTask sst = new SaveTask(subt.name, subt.id); sst.difficulty = subt.difficulty; st.subtasks.Add(sst); } saveTasks.Add(st); } saveData.tasks = saveTasks; /***** Completed Tasks */ List<SaveTask> cTasks = new List<SaveTask>(); foreach(Task c in completedTasks){ SaveTask st = new SaveTask(c.name, c.id); st.difficulty = c.difficulty; cTasks.Add(st); // TODO: parent task somehow? to display what the task was a child of? } saveData.completedTasks = cTasks; Serializer.Save(saveData); }