public PyTuple GetStationItemBits(CallInformation call) { int stationID = call.Client.EnsureCharacterIsInStation(); Station station = this.ItemFactory.GetStaticStation(stationID); return(new PyTuple(5) { [0] = station.StationType.HangarGraphicID, [1] = station.OwnerID, [2] = station.ID, [3] = station.Operations.ServiceMask, [4] = station.Type.ID }); }
public PyDataType RemoveImplantFromCharacter(PyInteger itemID, CallInformation call) { if (this.Character.Items.TryGetValue(itemID, out ItemEntity item) == false) { throw new CustomError("This implant is not in your brain!"); } // now destroy the item this.ItemFactory.DestroyItem(item); // notify the change call.Client.NotifyMultiEvent(OnItemChange.BuildLocationChange(item, this.Character.ID)); return(null); }
protected override BoundService CreateBoundInstance(PyDataType objectData, CallInformation call) { /* * objectData[0] => itemID (station/solarsystem) * objectData[1] => itemGroup */ PyTuple tupleData = objectData as PyTuple; if (this.MachoResolveObject(tupleData, 0, call) != this.NodeContainer.NodeID) { throw new CustomError("Trying to bind an object that does not belong to us!"); } return(new invbroker(this.ItemDB, this.ItemManager, this.NodeContainer, this.SystemManager, this.BoundServiceManager, tupleData[0] as PyInteger)); }
public PyDataType LookupStations(PyString criteria, PyDataType exactMatch, CallInformation call) { bool exact = false; if (exactMatch is PyBool exactBool) { exact = exactBool; } else if (exactMatch is PyInteger exactInteger) { exact = exactInteger != 0; } return(this.DB.LookupStations(criteria, exact)); }
/// <summary> /// Takes the given payload and searches in this service manager for the best service match to call the given method /// if possible /// </summary> /// <param name="boundID">The boundID to call at</param> /// <param name="call">The method to call</param> /// <param name="payload">Parameters for the method</param> /// <param name="callInformation">Any extra information for the method call</param> /// <returns>The result of the call</returns> /// <exception cref="ServiceDoesNotExistsException">If the boundID doesn't match any registered bound service</exception> /// <exception cref="ServiceDoesNotContainCallException">If the service was found but no matching call was found</exception> public PyDataType ServiceCall(int boundID, string call, PyTuple payload, CallInformation callInformation) { // relay the exception throw by the call try { BoundService serviceInstance = this.mBoundServices[boundID]; Log.Trace($"Calling {serviceInstance.GetType().Name}::{call} on bound service {boundID}"); if(serviceInstance is null) throw new ServiceDoesNotExistsException($"Bound Service {boundID}"); List<MethodInfo> methods = this.FindMethods(serviceInstance, $"(boundID {boundID}) {serviceInstance.GetType().Name}", call); if (FindSuitableMethod(methods, payload, callInformation, out object[] invokeParameters, out MethodInfo method) == false)
public PyDataType AssembleShip(PyList itemIDs, CallInformation call) { foreach (PyDataType itemID in itemIDs) { // ignore item if (itemID is PyInteger == false) { continue; } this.AssembleShip(itemID as PyInteger, call); } return(null); }
public PyDataType MarkMessagesRead(PyList messageIDs, CallInformation call) { // TODO: CHECK FOR PERMISSIONS ON lscChannelPermissions foreach (PyDataType messageID in messageIDs) { if (messageID is PyInteger == false) { continue; } this.MessagesDB.MarkMessagesRead(call.Client.EnsureCharacterIsSelected(), messageID as PyInteger); } return(null); }
public PyDataType GetSkillQueue(CallInformation call) { Character character = this.ItemFactory.GetItem <Character>(call.Client.EnsureCharacterIsSelected()); PyList skillQueueList = new PyList(character.SkillQueue.Count); int index = 0; foreach (Character.SkillQueueEntry entry in character.SkillQueue) { skillQueueList[index++] = entry; } return(skillQueueList); }
public PyDataType Board(PyInteger itemID, CallInformation call) { int callerCharacterID = call.Client.EnsureCharacterIsSelected(); // ensure the item is loaded somewhere in this node // this will usually be taken care by the EVE Client if (this.ItemManager.IsItemLoaded(itemID) == false) { throw new CustomError("Ships not loaded for player and hangar!"); } Ship newShip = this.ItemManager.GetItem(itemID) as Ship; Character character = this.ItemManager.GetItem(callerCharacterID) as Character; Ship currentShip = this.ItemManager.GetItem((int)call.Client.ShipID) as Ship; if (newShip.Singleton == false) { throw new UserError("TooFewSubSystemsToUndock"); } // TODO: CHECKS FOR IN-SPACE BOARDING! // check skills required to board the given ship newShip.EnsureOwnership(character); newShip.CheckPrerequisites(character); // move the character into this new ship character.LocationID = newShip.ID; // finally update the session call.Client.ShipID = newShip.ID; // notify the client about the change in location call.Client.NotifyItemLocationChange(character, ItemFlags.Pilot, currentShip.ID); character.Persist(); // ensure the character is not removed when the capsule is removed currentShip.RemoveItem(character); if (currentShip.Type.ID == (int)ItemTypes.Capsule) { // destroy the pod from the database this.ItemManager.DestroyItem(currentShip); // notify the player of the item change call.Client.NotifyItemLocationChange(currentShip, currentShip.Flag, this.Location.ID); } return(null); }
public PyDataType GetOrders(PyInteger typeID, CallInformation call) { call.Client.EnsureCharacterIsSelected(); // dirty little hack, but should do the trick this.CacheStorage.StoreCall( "marketProxy", "GetOrders_" + typeID, this.DB.GetOrders(call.Client.RegionID, call.Client.SolarSystemID2, typeID), DateTime.UtcNow.ToFileTimeUtc() ); PyDataType cacheHint = this.CacheStorage.GetHint("marketProxy", "GetOrders_" + typeID); return(CachedMethodCallResult.FromCacheHint(cacheHint)); }
public PyDataType GetContracts(CallInformation call) { if (this.mStationID == 0) { if (call.Client.ShipID == null) { throw new CustomError($"The character is not onboard any ship"); } return(this.DB.GetContractForShip(call.Client.EnsureCharacterIsSelected(), (int)call.Client.ShipID)); } else { return(this.DB.GetContractsForShipsOnStation(call.Client.EnsureCharacterIsSelected(), this.mStationID)); } }
public PyDataType BatchCertificateGrant(PyList certificateList, CallInformation call) { call.Client.EnsureCharacterIsSelected(); PyList result = new PyList(); foreach (PyInteger certificateID in certificateList) { if (this.GrantCertificate(certificateID, call) == true) { result.Add(certificateID); } } return(result); }
protected override BoundService CreateBoundInstance(PyDataType objectData, CallInformation call) { PyTuple tupleData = objectData as PyTuple; /* * objectData [0] => entityID (station or solar system) * objectData [1] => groupID (station or solar system) */ if (this.MachoResolveObject(tupleData, 0, call) != this.BoundServiceManager.Container.NodeID) { throw new CustomError("Trying to bind an object that does not belong to us!"); } return(new jumpCloneSvc(this.ItemDB, this.MarketDB, this.ItemManager, this.TypeManager, this.SystemManager, this.BoundServiceManager)); }
public PyDataType JoinFactionAsCharacter(PyInteger factionID, CallInformation call) { int callerCharacterID = call.Client.EnsureCharacterIsSelected(); // TODO: CHECK FOR PERMISSIONS, TO JOIN TO SOME FACTIONS THE CHARACTER REQUIRES AN INVITATION // check if the player joined a militia in the last 24 hours long minimumDateTime = DateTime.UtcNow.AddHours(-24).ToFileTimeUtc(); long lastTime = this.CharacterDB.GetLastFactionJoinDate(callerCharacterID); if (lastTime > minimumDateTime) { throw new FactionCharJoinDenied(MLS.UI_CORP_MILITIAJOIN_DENIED_TOOFREQUENT, TimeSpan.FromTicks(minimumDateTime - lastTime).Hours); } // first join the character to the militia corporation Faction faction = this.ItemFactory.Factions[factionID]; Character character = this.ItemFactory.GetItem <Character>(callerCharacterID); // build the notification of corporation change OnCorporationMemberChanged change = new OnCorporationMemberChanged(character.ID, call.Client.CorporationID, faction.MilitiaCorporationId); // add the character to the faction's and corp chat channel this.ChatDB.JoinEntityChannel(factionID, callerCharacterID); this.ChatDB.JoinEntityChannel(faction.MilitiaCorporationId, character.ID); this.ChatDB.JoinEntityMailingList(faction.MilitiaCorporationId, character.ID); // remove character from the old chat channel too this.ChatDB.LeaveChannel(character.CorporationID, character.ID); // this change implies a session change call.Client.CorporationID = faction.MilitiaCorporationId; call.Client.WarFactionID = factionID; // update the character's warfactionid too // set the new faction id and corporation character.WarFactionID = factionID; character.CorporationID = faction.MilitiaCorporationId; character.Corporation = this.ItemFactory.GetItem <Corporation>(faction.MilitiaCorporationId); character.CorporationDateTime = DateTime.UtcNow.ToFileTimeUtc(); // create employment record this.CharacterDB.CreateEmploymentRecord(character.ID, faction.MilitiaCorporationId, character.CorporationDateTime); // notify cluster about the corporation changes this.NotificationManager.NotifyCorporation(change.OldCorporationID, change); this.NotificationManager.NotifyCorporation(change.NewCorporationID, change); // save the character character.Persist(); return(null); }
private void GiveIskCmd(string[] argv, CallInformation call) { if (argv.Length < 3) { throw new SlashError("giveisk takes two arguments"); } string targetCharacter = argv[1]; if (double.TryParse(argv[2], out double iskQuantity) == false) { throw new SlashError("giveisk second argument must be the ISK quantity to give"); } int targetCharacterID = 0; int originCharacterID = call.Client.EnsureCharacterIsSelected(); double finalBalance = 0; if (targetCharacter == "me") { targetCharacterID = originCharacterID; } else { List <int> matches = this.CharacterDB.FindCharacters(targetCharacter); if (matches.Count > 1) { throw new SlashError("There's more than one character that matches the search criteria, please narrow it down"); } targetCharacterID = matches[0]; } using Wallet wallet = this.WalletManager.AcquireWallet(targetCharacterID, 1000); { if (iskQuantity < 0) { wallet.EnsureEnoughBalance(iskQuantity); wallet.CreateJournalRecord(MarketReference.GMCashTransfer, this.ItemFactory.SecureCommerceCommision.ID, null, -iskQuantity); } else { wallet.CreateJournalRecord(MarketReference.GMCashTransfer, this.ItemFactory.SecureCommerceCommision.ID, targetCharacterID, null, iskQuantity); } } }
public PyDataType GetStationExtraInfo(CallInformation call) { Rowset stations = new Rowset(new PyDataType [] { "stationID", "solarSystemID", "operationID", "stationTypeID", "ownerID" }); Rowset operationServices = new Rowset(new PyDataType[] { "operationID", "serviceID" }); Rowset services = new Rowset(new PyDataType[] { "serviceID", "serviceName" }); foreach (KeyValuePair <int, Station> pair in this.ItemManager.Stations) { stations.Rows.Add((PyList) new PyDataType [] { pair.Value.ID, pair.Value.LocationID, pair.Value.Operations.OperationID, pair.Value.StationType.ID, pair.Value.OwnerID }); } foreach (KeyValuePair <int, StationOperations> pair in this.StationManager.Operations) { foreach (int serviceID in pair.Value.Services) { operationServices.Rows.Add((PyList) new PyDataType[] { pair.Value.OperationID, serviceID }); } } foreach (KeyValuePair <int, string> pair in this.StationManager.Services) { services.Rows.Add((PyList) new PyDataType[] { pair.Key, pair.Value }); } return(new PyTuple(new PyDataType[] { stations, operationServices, services })); }
public PyDataType DeleteContract(PyInteger contractID, PyObjectData keyVal, CallInformation call) { using MySqlConnection connection = this.MarketDB.AcquireMarketLock(); try { // get contract type and status // get the items back to where they belong (if any) // } finally { this.MarketDB.ReleaseMarketLock(connection); } return(null); }
public PyDataType BatchCertificateGrant(PyList certificateList, CallInformation call) { int callerCharacterID = call.Client.EnsureCharacterIsSelected(); Character character = this.ItemFactory.GetItem <Character>(callerCharacterID); PyList <PyInteger> result = new PyList <PyInteger>(); Dictionary <int, Skill> skills = character.InjectedSkillsByTypeID; List <int> grantedCertificates = this.DB.GetCertificateListForCharacter(callerCharacterID); foreach (PyInteger certificateID in certificateList.GetEnumerable <PyInteger>()) { if (this.CertificateRelationships.TryGetValue(certificateID, out List <Relationship> relationships) == true) { bool requirementsMet = true; foreach (Relationship relationship in relationships) { if (relationship.ParentTypeID != 0 && (skills.TryGetValue(relationship.ParentTypeID, out Skill skill) == false || skill.Level < relationship.ParentLevel)) { requirementsMet = false; } if (relationship.ParentID != 0 && grantedCertificates.Contains(relationship.ParentID) == false) { requirementsMet = false; } } if (requirementsMet == false) { continue; } } // grant the certificate and add it to the list of granted certs this.DB.GrantCertificate(callerCharacterID, certificateID); // ensure the result includes that certificate list result.Add(certificateID); // add the cert to the list so certs that depend on others are properly granted grantedCertificates.Add(certificateID); } // notify the client about the granting of certificates call.Client.NotifyMultiEvent(new OnCertificateIssued()); return(result); }
public PyDataType GetMarketGroups(CallInformation call) { // check if the cache already exits if (this.CacheStorage.Exists("marketProxy", "GetMarketGroups") == false) { this.CacheStorage.StoreCall( "marketProxy", "GetMarketGroups", this.DB.GetMarketGroups(), DateTime.UtcNow.ToFileTimeUtc() ); } return(PyCacheMethodCallResult.FromCacheHint( this.CacheStorage.GetHint("marketProxy", "GetMarketGroups") )); }
public PyDataType ForgetChannel(PyInteger channelID, CallInformation call) { int callerCharacterID = call.Client.EnsureCharacterIsSelected(); // announce leaving, important in private channels PyDataType notification = GenerateLSCNotification("LeaveChannel", channelID, new PyTuple(0), call.Client); // get users in the channel that are online now PyList characters = this.DB.GetOnlineCharsOnChannel(channelID); call.Client.ClusterConnection.SendNotification("OnLSC", "charid", characters, notification); this.DB.LeaveChannel(channelID, callerCharacterID); return(null); }
public PyDataType GetPostAuthenticationMessage(CallInformation call) { if (this.mConfiguration.MessageType == AuthenticationMessageType.NoMessage) { return(null); } if (this.mConfiguration.MessageType == AuthenticationMessageType.HTMLMessage) { return(KeyVal.FromDictionary(new PyDictionary { ["message"] = this.mConfiguration.Message } )); } return(null); }
public PyDataType GetInventoryFromId(PyInteger itemID, PyInteger one, CallInformation call) { int callerCharacterID = call.Client.EnsureCharacterIsSelected(); ItemEntity inventoryItem = this.ItemManager.LoadItem(itemID); // also make sure it's a container if (inventoryItem is ItemInventory == false) { throw new ItemNotContainer(itemID); } // build the meta inventory item now ItemInventory inventoryByOwner = this.ItemManager.MetaInventoryManager.RegisterMetaInventoryForOwnerID(inventoryItem as ItemInventory, callerCharacterID); // create an instance of the inventory service and bind it to the item data return(BoundInventory.BindInventory(this.ItemDB, inventoryByOwner, ItemFlags.None, this.ItemManager, this.NodeContainer, this.BoundServiceManager)); }
public PyDataType GetStation(PyInteger stationID, CallInformation call) { // generate cache for this call, why is this being called for every item in the assets window // when a list is expanded?! if (this.CacheStorage.Exists("stationSvc", $"GetStation_{stationID}") == false) { this.CacheStorage.StoreCall( "stationSvc", $"GetStation_{stationID}", this.ItemFactory.Stations[stationID].GetStationInfo(), DateTime.UtcNow.ToFileTimeUtc() ); } return(CachedMethodCallResult.FromCacheHint( this.CacheStorage.GetHint("stationSvc", $"GetStation_{stationID}") )); }
public PyDataType GetPostAuthenticationMessage(CallInformation call) { if (this.mConfiguration.MessageType == AuthenticationMessageType.NoMessage) { return(new PyNone()); } if (this.mConfiguration.MessageType == AuthenticationMessageType.HTMLMessage) { PyDictionary keyvalData = new PyDictionary(); keyvalData["message"] = this.mConfiguration.Message; return(new PyObjectData("util.KeyVal", keyvalData)); } return(new PyNone()); }
public PyDataType GetReprocessingInfo(CallInformation call) { int stationID = call.Client.EnsureCharacterIsInStation(); Character character = this.ItemFactory.GetItem <Character>(call.Client.EnsureCharacterIsSelected()); double standing = GetStanding(character); return(new PyDictionary { ["yield"] = this.mStation.ReprocessingEfficiency, ["combinedyield"] = this.CalculateCombinedYield(character), ["wetake"] = new PyList(2) { [0] = CalculateTax(standing), [1] = standing }, }); }
public PyDataType GetQuotes(PyList itemIDs, CallInformation call) { Character character = this.ItemFactory.GetItem <Character>(call.Client.EnsureCharacterIsSelected()); PyDictionary <PyInteger, PyDataType> result = new PyDictionary <PyInteger, PyDataType>(); foreach (PyInteger itemID in itemIDs.GetEnumerable <PyInteger>()) { if (this.mInventory.Items.TryGetValue(itemID, out ItemEntity item) == false) { throw new MktNotOwner(); } result[itemID] = this.GetQuote(character, item); } return(result); }
public PyDataType CreateChannel(PyString name, CallInformation call) { int callerCharacterID = call.Client.EnsureCharacterIsSelected(); if (name.Length > 60) { throw new ChatCustomChannelNameTooLong(60); } bool mailingList = false; if (call.NamedPayload.ContainsKey("mailingList") == true) { mailingList = call.NamedPayload["mailingList"] as PyBool; } // create the channel in the database int channelID = (int)this.DB.CreateChannel(callerCharacterID, null, "Private Channel\\" + name, mailingList); // join the character to this channel this.DB.JoinChannel(channelID, callerCharacterID, ChatDB.CHATROLE_CREATOR); Rowset mods = this.DB.GetChannelMods(channelID); Rowset chars = this.DB.GetChannelMembers(channelID, callerCharacterID); // the extra field is at the end int extraIndex = chars.Header.Count - 1; // ensure they all have the owner information foreach (PyList row in chars.Rows) { // fill it with information row[extraIndex] = this.DB.GetExtraInfo(row[0] as PyInteger); } // retrieve back the information about the characters as there is ONE character in here // return the normal channel information return(new PyTuple(3) { [0] = this.DB.GetChannelInfo(channelID, callerCharacterID), [1] = mods, [2] = chars }); }
public PyDataType GetInventory(PyInteger containerID, PyNone none, CallInformation call) { int callerCharacterID = call.Client.EnsureCharacterIsSelected(); ItemFlags flag = ItemFlags.None; switch ((int)containerID) { case (int)ItemContainer.Wallet: flag = ItemFlags.Wallet; break; case (int)ItemContainer.Hangar: flag = ItemFlags.Hangar; break; case (int)ItemContainer.Character: flag = ItemFlags.Skill; break; case (int)ItemContainer.Global: flag = ItemFlags.None; break; default: throw new CustomError($"Trying to open container ID ({containerID.Value}) is not supported"); } // get the inventory item first ItemEntity inventoryItem = this.ItemManager.LoadItem(this.mObjectID); // also make sure it's a container if (inventoryItem is ItemInventory == false) { throw new ItemNotContainer(inventoryItem.ID); } // build the meta inventory item now ItemInventory inventoryByOwner = this.ItemManager.MetaInventoryManager.RegisterMetaInventoryForOwnerID(inventoryItem as ItemInventory, callerCharacterID); // create an instance of the inventory service and bind it to the item data return(BoundInventory.BindInventory(this.ItemDB, inventoryByOwner, flag, this.ItemManager, this.NodeContainer, this.BoundServiceManager)); }
public PyDataType CharStopTrainingSkill(CallInformation call) { // iterate the whole skill queue, stop it and recalculate points for the skills if (this.Character.SkillQueue.Count == 0) { return(null); } // only the skill on the front should have it's skillpoints recalculated Skill skill = this.Character.SkillQueue[0].Skill; if (skill.ExpiryTime > 0) { // get the total amount of minutes the skill would have taken to train completely long pointsLeft = (long)(skill.GetSkillPointsForLevel(this.Character.SkillQueue[0].TargetLevel) - skill.Points); TimeSpan timeLeft = TimeSpan.FromMinutes(pointsLeft / this.Character.GetSkillPointsPerMinute(skill)); DateTime endTime = DateTime.FromFileTimeUtc(skill.ExpiryTime); DateTime startTime = endTime.Subtract(timeLeft); TimeSpan timePassed = DateTime.UtcNow - startTime; // calculate the skill points to add double skillPointsToAdd = timePassed.TotalMinutes * this.Character.GetSkillPointsPerMinute(skill); skill.Points += skillPointsToAdd; } this.FreeSkillQueueTimers(); foreach (Character.SkillQueueEntry entry in this.Character.SkillQueue) { // mark the skill as stopped and store it in the database entry.Skill.ExpiryTime = 0; entry.Skill.Persist(); // notify the skill is not in training anymore call.Client.NotifyMultiEvent(new OnSkillTrainingStopped(entry.Skill)); // create history entry this.DB.CreateSkillHistoryRecord(entry.Skill.Type, this.Character, SkillHistoryReason.SkillTrainingCancelled, entry.Skill.Points); } return(null); }
public PyDataType LeaveChannel(PyDataType channel, PyInteger announce, CallInformation call) { int callerCharacterID = call.Client.EnsureCharacterIsSelected(); int channelID; string channelType; try { this.ParseChannelIdentifier(channel, out channelID, out channelType); } catch (InvalidDataException ex) { Log.Error("Error parsing channel identifier for LeaveChannel"); return(null); } // make sure the character is actually in the channel if (this.DB.IsCharacterMemberOfChannel(channelID, callerCharacterID) == false) { return(null); } if (channelType != ChatDB.CHANNEL_TYPE_CORPID && channelType != ChatDB.CHANNEL_TYPE_SOLARSYSTEMID2 && announce == 1) { // notify everyone in the channel only when it should PyDataType notification = GenerateLSCNotification("LeaveChannel", channel, new PyTuple(0), call.Client); if (channelType != ChatDB.CHANNEL_TYPE_NORMAL) { call.Client.ClusterConnection.SendNotification("OnLSC", channelType, new PyDataType [] { channel }, notification); } else { // get users in the channel that are online now PyList characters = this.DB.GetOnlineCharsOnChannel(channelID); call.Client.ClusterConnection.SendNotification("OnLSC", "charid", characters, notification); } } return(null); }
public TextCall(int messages, CallInformation callInformation) : base(callInformation) { Messages = messages; }
public DataCall(long kBytesUsed, CallInformation callInformation) : base(callInformation) { BytesUsed = kBytesUsed; }
public void StoreCallInformation(CallInformation callInformation) { try { } catch (Exception e) { MessageBox.Show(e.ToString()); } }