private static void TestGetLocalGridEntities(Character me, EVE.ISXEVE.EVE eve, ILogger logger) { //var entities = EntityRepository.GetLocalGridEntities(me, eve); eve.RefreshStandings(); var entities = eve.QueryEntities().Where(x => x.IsPC); //var anObj = LavishScript.Objects.GetObject("Local", "Romvex"); //logger.Log(anObj.ToString()); var pilot = new Pilot("Romvex "); logger.Log(pilot.ToString()); foreach (var entity in entities) { logger.Log(entity.Name); logger.Log(LavishScriptObject.IsNullOrInvalid(entity.Owner.ToFleetMember).ToString()); logger.Log(entity.Owner.CharID.ToString()); logger.Log(entity.Owner.Corp.ID.ToString()); logger.Log(entity.AllianceID.ToString()); var standing = me.StandingTo(entity.CharID, entity.Corp.ID, entity.AllianceID); logger.Log(standing.AllianceToAlliance.ToString()); logger.Log(standing.AllianceToCorp.ToString()); logger.Log(standing.AllianceToPilot.ToString()); logger.Log(standing.CorpToAlliance.ToString()); logger.Log(standing.CorpToCorp.ToString()); logger.Log(standing.CorpToPilot.ToString()); logger.Log(standing.MeToAlliance.ToString()); logger.Log(standing.MeToCorp.ToString()); logger.Log(standing.MeToPilot.ToString()); } }
/// <summary> /// Does the work. /// </summary> /// <param name="myMe">My me.</param> /// <param name="myEVE">My eve.</param> private void DoWork(Character myMe, EVE.ISXEVE.EVE myEVE) { if (CurrentBotState == BotState.Active) { try { var allEntities = EntityRepository.GetLocalGridEntities(myMe, myEVE).ToArray(); var engageableTargets = CombatHelper.FindEngageableTargets(myMe, myEVE, allEntities, EngageRules).ToList(); Entities = new ObservableCollection <EntityViewModel>(allEntities); foreach (var engageableTarget in engageableTargets) { logger.Log(engageableTarget.EntityName + " " + " Corp: " + engageableTarget.Entity.Owner.Corp.Name + " " + engageableTarget.Entity.Owner.Corp.ID + " AllyId: " + engageableTarget.Entity.Owner.AllianceID + " isFleet" + engageableTarget.Entity.FleetTag); } CombatHelper.Engage(myMe, myEVE, engageableTargets, EngageRules); } catch (Exception exc) { InnerSpace.Echo("DO WORK ERROR: " + exc.Message); } } }
private static void Pulse(object sender, LSEventArgs e) { using (new FrameLock(true)) { if (DateTime.Now > NextPulse) { DebugUI.Text = "VNI - " + Me.Name + " " + m_RoutineController.ActiveRoutine + " " + Constants.VERSION + " " + VNI.Me.ToEntity.Type; NextPulse = DateTime.Now.AddSeconds(PulseRate); Eve = new EVE.ISXEVE.EVE(); Me = new EVE.ISXEVE.Me(); MyShip = new EVE.ISXEVE.Ship(); //Update standings if (!refreshCompleted) { refreshCompleted = true; Initialise(); } if (DateTime.Now > EndTime) { f_Anomalies.lastAnomaly = true; } if (f_Ship.CheckIfCapsule()) { VNI.DebugUI.NewConsoleMessage("No ship, staying docked!"); InCapsule = true; } //Update shield Percentage label every pulse if (VNI.Me.InSpace) { DebugUI.updateShieldPctLabel((int)f_Ship.shieldPct()); } //Check if local is clear every pulse if (!f_Social.isSafe()) { m_RoutineController.ActiveRoutine = Routine.Flee; } //If shield pct is low flee station if (f_Ship.shieldPct() < 30) { m_RoutineController.ActiveRoutine = Routine.Flee; } //If bot is not paused begin ratting if (!Paused) { b_Ratting.Pulse(); DebugUI.updateTimeAndDateLabel(NextPulse); } } return; } }
protected override void PopulateItems(ref Dictionary <long, Entity> cache) { using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); foreach (Entity e in eve.QueryEntities()) { cache[e.ID] = e; } } }
// For retrieving other's orders public MarketOrder(EVE.ISXEVE.MarketOrder isxEveOrderObject) : base(isxEveOrderObject) { Type = isxEveOrderObject.Name; Station = isxEveOrderObject.Station; SolarSystem = isxEveOrderObject.SolarSystem; Region = isxEveOrderObject.Region; Duration = isxEveOrderObject.Duration; DateWhenLastModified = isxEveOrderObject.DateWhenIssued; TimeWhenLastModified = isxEveOrderObject.TimeWhenIssued; TimeStampWhenLastModified = (long)isxEveOrderObject.TimeStampWhenIssued; IsContraband = isxEveOrderObject.IsContraband; }
/// <summary> /// Called when [time setup]. /// </summary> private void OneTimeSetup() { Frame.Wait(true); MyEve = new EVE.ISXEVE.EVE(); MyMe = new Me(); MyEve.RefreshStandings(); MyEve.RefreshBookmarks(); ActivePilot = MyMe.Name; Frame.Unlock(); }
/// <summary> /// Gets the local grid entities. /// </summary> /// <param name="myMe"></param> /// <param name="myEVE">My eve.</param> /// <returns></returns> public static IEnumerable<EntityViewModel> GetLocalGridEntities(Character myMe, EVE.ISXEVE.EVE myEVE) { try { var entities = myEVE.QueryEntities().Where(entity => entity.IsPC && myMe.CharID != entity.CharID).ToArray(); var oEntities = new List<EntityViewModel>(); foreach (var entity in entities) { var standings = EntityHelper.ComputeStandings(myMe, entity); var newEntity = new EntityViewModel {Entity = entity, EntityStandings = standings}; var cachedEntity = EntityCache.Get(newEntity); if (cachedEntity == null) { EntityCache.Add(newEntity); } else { if (cachedEntity.EntityStandings != newEntity.EntityStandings) { if (newEntity.EntityStandings > cachedEntity.EntityStandings) { EntityCache.Remove(newEntity); EntityCache.Add(newEntity); } if (newEntity.EntityStandings == 0 && cachedEntity.EntityStandings != 0) { newEntity.EntityStandings = cachedEntity.EntityStandings; } } } oEntities.Add(newEntity); } return oEntities; } catch (Exception e) { InnerSpace.Echo("GET LOCAL GRID ENTITIES ERROR :" + e.Message); return new List<EntityViewModel>(); } }
public void CheckCache(bool forceRepopulate = false) { if (RepopulateCache || forceRepopulate) { EntityCache.Clear(); EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); List <Entity> entities = eve.QueryEntities(); foreach (Entity e in entities) { EntityCache.Add(e.ID, e); } } RepopulateCache = false; }
public override bool DoWork() { using (new FrameLock(true)) { Me me = new Me(); EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); if (!me.InSpace && me.InStation && !Undocked) { eve.Execute(ExecuteCommand.CmdExitStation); Undocked = true; } else if (Undocked && me.InSpace && !me.InStation) { return(true); } } return(false); }
/// <summary> /// Get the information of the character. /// </summary> public bool LoadCharacterInfo() { Me me; using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); // me is not persistent, we can't just keep a static reference somewhere,have to renew every frame; me = new Me(); name = me.Name; currentStationID = me.StationID; // TODO: Support remote modify in future. daytradingLevel = 0; } bool succeed = !string.IsNullOrEmpty(Name); return succeed; }
/// <summary> /// Does the tackle and returns the current valid engageable targets /// </summary> /// <param name="myMe">My me.</param> /// <param name="myEve">My eve.</param> /// <param name="entities">The entities.</param> /// <param name="engageRules">The engage rules.</param> public static void Engage(Character myMe, EVE.ISXEVE.EVE myEve, IEnumerable <EntityViewModel> entities, EngageRules engageRules) { IEnumerable <EntityViewModel> targettedNeuts = TargetNeuts(entities).ToList(); //Tackle closest targetted neut EntityViewModel closestTargetedNeut = null; if (targettedNeuts.Any()) { closestTargetedNeut = EntityHelper.FindClosestEntity(targettedNeuts); } if (closestTargetedNeut != null) { if (engageRules.GoBrawl ?? DefaultGoBrawl) { closestTargetedNeut.Entity.MakeActiveTarget(); closestTargetedNeut.Entity.Orbit(500); } ActivateModules(myMe, myEve, engageRules); } else { var closestNeutNotTargetted = EntityHelper.FindClosestEntity(entities); if (closestNeutNotTargetted != null) { ActivateModules(myMe, myEve, engageRules); if (engageRules.GoBrawl ?? DefaultGoBrawl) { closestNeutNotTargetted.Entity.Approach(); myEve.Execute(ExecuteCommand.CmdAccelerate); } } } }
/// <summary> /// Finds the engageable targets. /// </summary> /// <param name="myMe">My me.</param> /// <param name="myEVE">My eve.</param> /// <param name="entities">The entities.</param> /// <param name="engageRules">The engage rules.</param> /// <returns></returns> public static IEnumerable <EntityViewModel> FindEngageableTargets(Character myMe, EVE.ISXEVE.EVE myEVE, IEnumerable <EntityViewModel> entities, EngageRules engageRules) { var allNeutrals = entities.Where( x => x.Entity.IsValid && x.EntityStandings <= 0 && x.EntityDistanceTo <= (engageRules.MaxRange ?? DefaultEngageRange) ); if (!allNeutrals.Any()) { return(new List <EntityViewModel>()); } //sort by capsule allNeutrals = allNeutrals.OrderBy(x => x.EntityGroup); var limitedTargets = allNeutrals.Take((int)myMe.MaxLockedTargets); return(limitedTargets); }
/// <summary> /// Get the information of the character. /// </summary> public bool LoadCharacterInfo() { Me me; using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); // me is not persistent, we can't just keep a static reference somewhere,have to renew every frame; me = new Me(); name = me.Name; currentStationID = me.StationID; // TODO: Support remote modify in future. daytradingLevel = 0; } bool succeed = !string.IsNullOrEmpty(Name); return(succeed); }
public override bool DoWork() { using (new FrameLock(true)) { if (Desto == null) { return(false); } EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); Me me = new Me(); if (me.SolarSystemID == Desto.ID) { return(true); } List <int> Waypoints = eve.GetWaypoints(); if (Waypoints.Count > 1 && Waypoints.Contains(Desto.ID)) { eve.ClearAllWaypoints(); // Wait till next pulse return(false); } else if (Waypoints.Count == 1 && !Waypoints.Contains(Desto.ID)) { Desto.SetDestination(); return(false); } if (!me.AutoPilotOn) { eve.Execute(ExecuteCommand.CmdToggleAutopilot); return(false); } return(false); } }
public void LoadMarketOrderInfo() { Log.WriteLog("Trying to load market orders."); List <MyOrder> retrivedOrders = null; Me me; bool success; using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); // me is not persistent, we can't just keep a static reference somewhere, have to renew every frame; me = new Me(); success = me.UpdateMyOrders(); } if (success) { Log.WriteLog("Fired update order request, wait to get result."); int counter = 0; while (retrivedOrders == null && counter < 100) { Frame.Wait(false); using (new FrameLock(true)) { counter++; // me is not persistent, we can't just keep a static reference somewhere,have to renew every frame; me = new Me(); // IMPORTANT: This is shallow copy, we need to finish all DEEP copy value operations while locked, otherwise the memory will be flushed; retrivedOrders = me.GetMyOrders(); if (retrivedOrders != null) { if (ValidateOrderData(retrivedOrders)) { _combineNewOrder(retrivedOrders); } else { Log.WriteLog("Found invalid data in retrived order, retrying."); // Enter next loop; retrivedOrders = null; } } } } if (retrivedOrders != null) { Log.WriteLog("Got " + retrivedOrders.Count.ToString() + " orders with (" + counter.ToString() + ") attempts."); } else { Log.WriteLog("Failed to load orders with (" + counter.ToString() + ") attempts."); } } else { Log.WriteLog("Failed to send update order request."); } Log.WriteLog("Done loading market orders."); }
/// <summary> /// Does the work. /// </summary> /// <param name="myMe">My me.</param> /// <param name="myEVE">My eve.</param> private void DoWork(Character myMe, EVE.ISXEVE.EVE myEVE) { if (CurrentBotState == BotState.Active) { try { var allEntities = EntityRepository.GetLocalGridEntities(myMe, myEVE).ToArray(); var engageableTargets = CombatHelper.FindEngageableTargets(myMe, myEVE, allEntities, EngageRules).ToList(); Entities = new ObservableCollection<EntityViewModel>(allEntities); foreach (var engageableTarget in engageableTargets) { logger.Log(engageableTarget.EntityName + " " + " Corp: " + engageableTarget.Entity.Owner.Corp.Name + " " + engageableTarget.Entity.Owner.Corp.ID + " AllyId: " + engageableTarget.Entity.Owner.AllianceID + " isFleet" + engageableTarget.Entity.FleetTag); } CombatHelper.Engage(myMe, myEVE, engageableTargets, EngageRules); } catch (Exception exc) { InnerSpace.Echo("DO WORK ERROR: " + exc.Message); } } }
/// <summary> /// Does the tackle and returns the current valid engageable targets /// </summary> /// <param name="myMe">My me.</param> /// <param name="myEve">My eve.</param> /// <param name="entities">The entities.</param> /// <param name="engageRules">The engage rules.</param> public static void Engage(Character myMe, EVE.ISXEVE.EVE myEve, IEnumerable<EntityViewModel> entities, EngageRules engageRules) { IEnumerable<EntityViewModel> targettedNeuts = TargetNeuts(entities).ToList(); //Tackle closest targetted neut EntityViewModel closestTargetedNeut = null; if (targettedNeuts.Any()) { closestTargetedNeut = EntityHelper.FindClosestEntity(targettedNeuts); } if (closestTargetedNeut != null) { if (engageRules.GoBrawl ?? DefaultGoBrawl) { closestTargetedNeut.Entity.MakeActiveTarget(); closestTargetedNeut.Entity.Orbit(500); } ActivateModules(myMe, myEve, engageRules); } else { var closestNeutNotTargetted = EntityHelper.FindClosestEntity(entities); if (closestNeutNotTargetted != null) { ActivateModules(myMe, myEve, engageRules); if (engageRules.GoBrawl ?? DefaultGoBrawl) { closestNeutNotTargetted.Entity.Approach(); myEve.Execute(ExecuteCommand.CmdAccelerate); } } } }
/// <summary> /// Finds the engageable targets. /// </summary> /// <param name="myMe">My me.</param> /// <param name="myEVE">My eve.</param> /// <param name="entities">The entities.</param> /// <param name="engageRules">The engage rules.</param> /// <returns></returns> public static IEnumerable<EntityViewModel> FindEngageableTargets(Character myMe, EVE.ISXEVE.EVE myEVE, IEnumerable<EntityViewModel> entities, EngageRules engageRules) { var allNeutrals = entities.Where( x => x.Entity.IsValid && x.EntityStandings <= 0 && x.EntityDistanceTo <= (engageRules.MaxRange ?? DefaultEngageRange) ); if (!allNeutrals.Any()) { return new List<EntityViewModel>(); } //sort by capsule allNeutrals = allNeutrals.OrderBy(x => x.EntityGroup); var limitedTargets = allNeutrals.Take((int) myMe.MaxLockedTargets); return limitedTargets; }
/// <summary> /// Activates the tackle modules. /// </summary> /// <param name="myMe">My me.</param> /// <param name="myEve">My eve.</param> /// <param name="engageRules"></param> public static void ActivateModules(Character myMe, EVE.ISXEVE.EVE myEve, EngageRules engageRules) { var modules = myMe.Ship.GetModules(); foreach (var module in modules) { var mItem = module.ToItem; var name = mItem.Name.ToLower(); if (name.Contains("sensor booster")) { module.Activate(); } else if (name.Contains("probe")) { //skip } else if (name.Contains("booster")) { if (engageRules.UseRepairer != null && engageRules.UseRepairer.Value) { module.Activate(); } } else if (name.Contains("repairer")) { if (engageRules.UseRepairer != null && engageRules.UseRepairer.Value) { module.Activate(); } } else if (name.Contains("cloak")) { module.Deactivate(); } else if (name.Contains("cyno")) { //skip } else if (name.Contains("bomb")) { //skip } else if (name.Contains("microwarp")) { if (engageRules.UsePropulsion ?? DefaultActivatePropulsion) { module.Activate(); } } else if (name.Contains("afterburner")) { if (engageRules.UsePropulsion ?? DefaultActivatePropulsion) { module.Activate(); } } else { module.Activate(); } } //engage drones last because modules might improve their effectiveness var myDrones = myMe.GetActiveDrones().Select(x => x.ID).ToList(); myEve.DronesEngageMyTarget(myDrones); }
/// <summary> /// Gets the local grid entities. /// </summary> /// <param name="myMe"></param> /// <param name="myEVE">My eve.</param> /// <returns></returns> public static IEnumerable <EntityViewModel> GetLocalGridEntities(Character myMe, EVE.ISXEVE.EVE myEVE) { try { var entities = myEVE.QueryEntities().Where(entity => entity.IsPC && myMe.CharID != entity.CharID).ToArray(); var oEntities = new List <EntityViewModel>(); foreach (var entity in entities) { var standings = EntityHelper.ComputeStandings(myMe, entity); var newEntity = new EntityViewModel { Entity = entity, EntityStandings = standings }; var cachedEntity = EntityCache.Get(newEntity); if (cachedEntity == null) { EntityCache.Add(newEntity); } else { if (cachedEntity.EntityStandings != newEntity.EntityStandings) { if (newEntity.EntityStandings > cachedEntity.EntityStandings) { EntityCache.Remove(newEntity); EntityCache.Add(newEntity); } if (newEntity.EntityStandings == 0 && cachedEntity.EntityStandings != 0) { newEntity.EntityStandings = cachedEntity.EntityStandings; } } } oEntities.Add(newEntity); } return(oEntities); } catch (Exception e) { InnerSpace.Echo("GET LOCAL GRID ENTITIES ERROR :" + e.Message); return(new List <EntityViewModel>()); } }
public MarketSituation GetMarketSituation() { Log.WriteLog("Trying to get the market situation of \"" + this.Type.ToString() + "\"."); List<EVE.ISXEVE.MarketOrder> retrivedOrders = null; MarketSituation result = null; bool success; using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); success = eve.FetchMarketOrders(this.TypeID); } if (success) { Log.WriteLog("Fired fetching orders request, wait to get result."); int counter = 0; while (retrivedOrders == null && counter < 100) { Frame.Wait(false); using (new FrameLock(true)) { counter++; EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); // IMPORTANT: This is shallow copy, we need to finish all DEEP copy value operations while locked, otherwise the memory will be flushed; retrivedOrders = eve.GetMarketOrders(this.TypeID); if (retrivedOrders != null) { if (MarketOrderSet.ValidateOrderData(retrivedOrders)) { // Prepare my own order id list to speed up the combine. List<long> MyOwnOrderIds = new List<long>(); foreach (MyMarketOrder mmo in _orderList) { if (mmo.TypeID == TypeID) { MyOwnOrderIds.Add(mmo.ID); } } result = new MarketSituation(retrivedOrders, MyOwnOrderIds); } else { Log.WriteLog("Found invalid data in retrived order, retrying."); // Enter next loop; retrivedOrders = null; } } } } if (retrivedOrders != null) { Log.WriteLog("Got " + retrivedOrders.Count.ToString() + " orders with (" + counter.ToString() + ") attempts."); } else { Log.WriteLog("Failed to load orders with (" + counter.ToString() + ") attempts."); } } else { Log.WriteLog("Failed to send update order request."); } Log.WriteLog("Done loading market orders."); return result; }
private void _onFrame(object sender, LSEventArgs e) { if (IsEnabled && DateTime.Now.CompareTo(NextPulse) >= 0) { NextPulse = DateTime.Now.AddMilliseconds(PulseFrequecy); EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); timer.Start(); entities = eve.GetCachedEntities(); timer.Stop(); messages.Add(String.Format("Getting {0} entities took: {1}.", entities.Count, timer.Elapsed)); timer.Reset(); //int id = 0; //double distance = 0; timer2.Start(); foreach (CachedEntity en in entities) { //timer.Start(); //id = en.ID; //distance = en.Distance; //timer.Stop(); //messages.Add(String.Format("Getting ID {0} took: {1} ms", id, timer.ElapsedMilliseconds)); //messages.Add(String.Format("Getting distance {0} took: {1} ms", en.Distance, timer.ElapsedMilliseconds)); //messages.Add(String.Format("Getting name {0} took: {1} ms", en.Name, timer.ElapsedMilliseconds)); //timer.Reset(); string Name; int GroupID, TypeID, CategoryID; Int64 ID; double ShieldPct, ArmorPct, StructurePct, Distance; bool BeingTargeted, IsLockedTarget, IsNPC, IsPC, IsTargetingMe; StartMethodProfiling("CE_Name"); Name = en.Name; EndMethodProfiling(); StartMethodProfiling("CE_ID"); ID = en.ID; EndMethodProfiling(); StartMethodProfiling("CE_GroupID"); GroupID = en.GroupID; EndMethodProfiling(); StartMethodProfiling("CE_TypeID"); TypeID = en.TypeID; EndMethodProfiling(); StartMethodProfiling("CE_ShieldPct"); ShieldPct = en.ShieldPct; EndMethodProfiling(); StartMethodProfiling("CE_ArmorPct"); ArmorPct = en.ArmorPct; EndMethodProfiling(); StartMethodProfiling("CE_StructurePct"); StructurePct = en.StructurePct; EndMethodProfiling(); StartMethodProfiling("CE_Distance"); Distance = en.Distance; EndMethodProfiling(); StartMethodProfiling("CE_BeingTargeted"); BeingTargeted = en.BeingTargeted; EndMethodProfiling(); //CanLoot = en.CanLoot; StartMethodProfiling("CE_CategoryID"); CategoryID = en.CategoryID; EndMethodProfiling(); StartMethodProfiling("CE_IsLockedTarget"); IsLockedTarget = en.IsLockedTarget; EndMethodProfiling(); StartMethodProfiling("CE_IsNPC"); IsNPC = en.IsNPC; EndMethodProfiling(); StartMethodProfiling("CE_IsPC"); IsPC = en.IsPC; EndMethodProfiling(); StartMethodProfiling("CE_IsTargetingMe"); IsTargetingMe = en.IsTargetingMe; EndMethodProfiling(); printed = true; if (en.GroupID == 12) { messages.Add("Found CachedEntity of groupID 12:"); messages.Add(String.Format("Name: {0}, ID: {1}", en.Name, en.ID)); } } timer2.Stop(); messages.Add(String.Format("Iteration of {0} entities took {1}.", entities.Count, timer2.Elapsed)); timer2.Reset(); foreach (string s in messages) { InnerSpaceAPI.InnerSpace.Echo(String.Format("ISXEVE_EntityIterationProfiler: {0}", s)); } messages.Clear(); //IsEnabled = false; printed = false; } }
public void Modify(double newPrice) { Debug.Assert(newPrice > 0); Log.WriteLog("Trying to confirm order " + this.ID.ToString() + ": \"" + this.Type.ToString() + "\" before modifying."); List<MyOrder> retrivedOrders = null; Me me; bool success; using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); // me is not persistent, we can't just keep a static reference somewhere, have to renew every frame; me = new Me(); success = me.UpdateMyOrders(); } if (success) { Log.WriteLog("Fired update order request, wait to get result."); int counter = 0; while (retrivedOrders == null && counter < 100) { Frame.Wait(false); using (new FrameLock(true)) { counter++; // me is not persistent, we can't just keep a static reference somewhere,have to renew every frame; me = new Me(); EVE.ISXEVE.Character.OrderType orderType = this.OrderType == OrderType.Buy ? EVE.ISXEVE.Character.OrderType.Buy : EVE.ISXEVE.Character.OrderType.Sell; // IMPORTANT: This is shallow copy, we need to finish all DEEP copy value operations while locked, otherwise the memory will be flushed; retrivedOrders = me.GetMyOrders(orderType, this.TypeID); if (retrivedOrders != null) { if (MarketOrderSet.ValidateOrderData(retrivedOrders)) { MyOrder orderToModify = null; foreach (MyOrder o in retrivedOrders) { if (o.ID == ID) { orderToModify = o; break; } } if (orderToModify != null) { Log.WriteLog("Confirmed order with (" + counter.ToString() + ") attempts."); DateTime lastModifiedTime = new System.DateTime(1601, 1, 1).AddSeconds(orderToModify.TimeStampWhenIssued / 10000000); //real cool down takes 5 minutes if (lastModifiedTime.AddMilliseconds(301000) < System.DateTime.UtcNow) { orderToModify.Modify(newPrice); Price = newPrice; ModifyCoolDownEndTime = System.DateTime.UtcNow.AddMilliseconds(_config.RandomizedOrderModifyIntervalInMilliSec); //I think the date, time and timestamp dont need updating. Log.WriteLog("Order " + this.ID.ToString() + ": \"" + this.Type.ToString() + "\" modified"); } else { ModifyCoolDownEndTime = lastModifiedTime.AddMilliseconds(_config.RandomizedOrderModifyIntervalInMilliSec); Log.WriteLog("Order cooldown not finished yet. Job \"Modify\" cancelled."); } } else { Log.WriteLog("Failed to find order to modify with (" + counter.ToString() + ") attempts. Job \"Modify\" cancelled."); } } else { Log.WriteLog("Found invalid data in retrived order, retrying."); // Enter next loop; retrivedOrders = null; } } } } } else { Log.WriteLog("Failed to send update order request. Job \"Modify\" cancelled."); } }
public void Modify(double newPrice) { Debug.Assert(newPrice > 0); Log.WriteLog("Trying to confirm order " + this.ID.ToString() + ": \"" + this.Type.ToString() + "\" before modifying."); List <MyOrder> retrivedOrders = null; Me me; bool success; using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); // me is not persistent, we can't just keep a static reference somewhere, have to renew every frame; me = new Me(); success = me.UpdateMyOrders(); } if (success) { Log.WriteLog("Fired update order request, wait to get result."); int counter = 0; while (retrivedOrders == null && counter < 100) { Frame.Wait(false); using (new FrameLock(true)) { counter++; // me is not persistent, we can't just keep a static reference somewhere,have to renew every frame; me = new Me(); EVE.ISXEVE.Character.OrderType orderType = this.OrderType == OrderType.Buy ? EVE.ISXEVE.Character.OrderType.Buy : EVE.ISXEVE.Character.OrderType.Sell; // IMPORTANT: This is shallow copy, we need to finish all DEEP copy value operations while locked, otherwise the memory will be flushed; retrivedOrders = me.GetMyOrders(orderType, this.TypeID); if (retrivedOrders != null) { if (MarketOrderSet.ValidateOrderData(retrivedOrders)) { MyOrder orderToModify = null; foreach (MyOrder o in retrivedOrders) { if (o.ID == ID) { orderToModify = o; break; } } if (orderToModify != null) { Log.WriteLog("Confirmed order with (" + counter.ToString() + ") attempts."); DateTime lastModifiedTime = new System.DateTime(1601, 1, 1).AddSeconds(orderToModify.TimeStampWhenIssued / 10000000); //real cool down takes 5 minutes if (lastModifiedTime.AddMilliseconds(301000) < System.DateTime.UtcNow) { orderToModify.Modify(newPrice); Price = newPrice; ModifyCoolDownEndTime = System.DateTime.UtcNow.AddMilliseconds(_config.RandomizedOrderModifyIntervalInMilliSec); //I think the date, time and timestamp dont need updating. Log.WriteLog("Order " + this.ID.ToString() + ": \"" + this.Type.ToString() + "\" modified"); } else { ModifyCoolDownEndTime = lastModifiedTime.AddMilliseconds(_config.RandomizedOrderModifyIntervalInMilliSec); Log.WriteLog("Order cooldown not finished yet. Job \"Modify\" cancelled."); } } else { Log.WriteLog("Failed to find order to modify with (" + counter.ToString() + ") attempts. Job \"Modify\" cancelled."); } } else { Log.WriteLog("Found invalid data in retrived order, retrying."); // Enter next loop; retrivedOrders = null; } } } } } else { Log.WriteLog("Failed to send update order request. Job \"Modify\" cancelled."); } }
// For retrieving other's orders public MarketOrderBase(EVE.ISXEVE.MarketOrder isxEveOrderObject) { ID = isxEveOrderObject.ID; TypeID = isxEveOrderObject.TypeID; OrderType = isxEveOrderObject.IsBuyOrder ? OrderType.Buy : OrderType.Sell; QuantityRemaining = isxEveOrderObject.QuantityRemaining; InitialQuantity = isxEveOrderObject.InitialQuantity; Price = isxEveOrderObject.Price; StationID = isxEveOrderObject.StationID; SolarSystemID = isxEveOrderObject.SolarSystemID; RegionID = isxEveOrderObject.RegionID; MinQuantityToBuy = isxEveOrderObject.MinQuantityToBuy; Range = isxEveOrderObject.Range; }
public MarketSituation GetMarketSituation() { Log.WriteLog("Trying to get the market situation of \"" + this.Type.ToString() + "\"."); List <EVE.ISXEVE.MarketOrder> retrivedOrders = null; MarketSituation result = null; bool success; using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); success = eve.FetchMarketOrders(this.TypeID); } if (success) { Log.WriteLog("Fired fetching orders request, wait to get result."); int counter = 0; while (retrivedOrders == null && counter < 100) { Frame.Wait(false); using (new FrameLock(true)) { counter++; EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); // IMPORTANT: This is shallow copy, we need to finish all DEEP copy value operations while locked, otherwise the memory will be flushed; retrivedOrders = eve.GetMarketOrders(this.TypeID); if (retrivedOrders != null) { if (MarketOrderSet.ValidateOrderData(retrivedOrders)) { // Prepare my own order id list to speed up the combine. List <long> MyOwnOrderIds = new List <long>(); foreach (MyMarketOrder mmo in _orderList) { if (mmo.TypeID == TypeID) { MyOwnOrderIds.Add(mmo.ID); } } result = new MarketSituation(retrivedOrders, MyOwnOrderIds); } else { Log.WriteLog("Found invalid data in retrived order, retrying."); // Enter next loop; retrivedOrders = null; } } } } if (retrivedOrders != null) { Log.WriteLog("Got " + retrivedOrders.Count.ToString() + " orders with (" + counter.ToString() + ") attempts."); } else { Log.WriteLog("Failed to load orders with (" + counter.ToString() + ") attempts."); } } else { Log.WriteLog("Failed to send update order request."); } Log.WriteLog("Done loading market orders."); return(result); }
public void LoadMarketOrderInfo() { Log.WriteLog("Trying to load market orders."); List<MyOrder> retrivedOrders = null; Me me; bool success; using (new FrameLock(true)) { EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE(); // me is not persistent, we can't just keep a static reference somewhere, have to renew every frame; me = new Me(); success = me.UpdateMyOrders(); } if (success) { Log.WriteLog("Fired update order request, wait to get result."); int counter = 0; while (retrivedOrders == null && counter < 100) { Frame.Wait(false); using (new FrameLock(true)) { counter++; // me is not persistent, we can't just keep a static reference somewhere,have to renew every frame; me = new Me(); // IMPORTANT: This is shallow copy, we need to finish all DEEP copy value operations while locked, otherwise the memory will be flushed; retrivedOrders = me.GetMyOrders(); if (retrivedOrders != null) { if (ValidateOrderData(retrivedOrders)) { _combineNewOrder(retrivedOrders); } else { Log.WriteLog("Found invalid data in retrived order, retrying."); // Enter next loop; retrivedOrders = null; } } } } if (retrivedOrders != null) { Log.WriteLog("Got " + retrivedOrders.Count.ToString() + " orders with (" + counter.ToString() + ") attempts."); } else { Log.WriteLog("Failed to load orders with (" + counter.ToString() + ") attempts."); } } else { Log.WriteLog("Failed to send update order request."); } Log.WriteLog("Done loading market orders."); }