Exemplo n.º 1
0
        private void OpenRequest(bool open, long identityId)
        {
            AdminSettingsEnum enum2;
            MyPlayer          playerFromCharacter;
            MyRelationsBetweenPlayerAndBlock userRelationToOwner = base.GetUserRelationToOwner(identityId);
            MyIdentity identity = MySession.Static.Players.TryGetIdentity(identityId);

            if ((identity == null) || (identity.Character == null))
            {
                playerFromCharacter = null;
            }
            else
            {
                playerFromCharacter = MyPlayer.GetPlayerFromCharacter(identity.Character);
            }
            MyPlayer player = playerFromCharacter;
            bool     flag   = false;

            if (((player != null) && !userRelationToOwner.IsFriendly()) && MySession.Static.RemoteAdminSettings.TryGetValue(player.Client.SteamUserId, out enum2))
            {
                flag = enum2.HasFlag(AdminSettingsEnum.UseTerminals);
            }
            if (userRelationToOwner.IsFriendly() | flag)
            {
                this.Open = open;
            }
        }
Exemplo n.º 2
0
        public static bool TryGetPlayerByNameOrId(string nameOrId, out MyIdentity identity)
        {
            identity = null;
            if (ulong.TryParse(nameOrId, out var steamId))
            {
                var id0 = MySession.Static.Players.TryGetIdentityId(steamId);
                identity = MySession.Static.Players.TryGetIdentity(id0);

                return(identity != null);
            }

            if (long.TryParse(nameOrId, out var id1))
            {
                identity = MySession.Static.Players.TryGetIdentity(id1);

                return(identity != null);
            }

            foreach (var id3 in MySession.Static.Players.GetAllIdentities())
            {
                if (string.IsNullOrEmpty(id3.DisplayName) || !id3.DisplayName.Equals(nameOrId))
                {
                    continue;
                }
                identity = id3;
                return(identity != null);
            }

            identity = null;
            return(false);
        }
Exemplo n.º 3
0
        private CheckResult FixGroups(List <MyCubeGrid> groups, long playerId)
        {
            if (groups.Count == 0)
            {
                return(CheckResult.GRID_NOT_FOUND);
            }

            var result = CheckGroups(groups, out List <MyCubeGrid> group, playerId, ShipFixerPlugin.Instance.FactionFixEnabled);

            if (result != CheckResult.OK)
            {
                return(result);
            }

            MyIdentity executingPlayer = null;

            if (playerId != 0)
            {
                foreach (var identity in MySession.Static.Players.GetAllIdentities())
                {
                    if (identity.IdentityId == playerId)
                    {
                        executingPlayer = identity;
                    }
                }
            }

            return(FixGroup(group, executingPlayer));
        }
Exemplo n.º 4
0
        public static void Login(IPlayer p)
        {
            if (p == null)
            {
                return;
            }

            MyIdentity id = AlliancePlugin.GetIdentityByNameOrId(p.SteamId.ToString());

            if (id == null)
            {
                return;
            }
            IMyFaction playerFac = MySession.Static.Factions.GetPlayerFaction(id.IdentityId);
            MyFaction  arrr      = MySession.Static.Factions.TryGetFactionByTag("arrr");

            if (arrr != null)
            {
                if (playerFac != null && !MySession.Static.Factions.AreFactionsEnemies(arrr.FactionId, FacUtils.GetPlayersFaction(id.IdentityId).FactionId))
                {
                    Sandbox.Game.Multiplayer.MyFactionCollection.DeclareWar(playerFac.FactionId, arrr.FactionId);
                }
            }

            MyFaction ACME = MySession.Static.Factions.TryGetFactionByTag("ACME");

            if (ACME != null)
            {
                MySession.Static.Factions.SetReputationBetweenPlayerAndFaction(id.IdentityId, ACME.FactionId, 0);
                MySession.Static.Factions.AddFactionPlayerReputation(id.IdentityId, ACME.FactionId, 0);
            }
            MyFaction GAIA = MySession.Static.Factions.TryGetFactionByTag("GAIA");

            if (GAIA != null)
            {
                MySession.Static.Factions.SetReputationBetweenPlayerAndFaction(id.IdentityId, GAIA.FactionId, 0);
                MySession.Static.Factions.AddFactionPlayerReputation(id.IdentityId, GAIA.FactionId, 0);
            }
            MyFaction wolf = MySession.Static.Factions.TryGetFactionByTag("WOLF");

            if (wolf != null)
            {
                if (playerFac != null && !MySession.Static.Factions.AreFactionsEnemies(wolf.FactionId, FacUtils.GetPlayersFaction(id.IdentityId).FactionId))
                {
                    Sandbox.Game.Multiplayer.MyFactionCollection.DeclareWar(playerFac.FactionId, wolf.FactionId);
                }
            }
            if (File.Exists(AlliancePlugin.path + "//PlayerData//" + p.SteamId + ".xml") && playerFac != null)
            {
                PlayerData data = utils.ReadFromXmlFile <PlayerData>(AlliancePlugin.path + "//PlayerData//" + p.SteamId + ".xml");
                if (data.InAllianceChat)
                {
                    if (AlliancePlugin.GetAllianceNoLoading(playerFac as MyFaction) != null)
                    {
                        PeopleInAllianceChat.Remove(p.SteamId);
                        PeopleInAllianceChat.Add(p.SteamId, AlliancePlugin.GetAllianceNoLoading(playerFac as MyFaction).AllianceId);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private static void CustomIdentityTest()
        {
            var id = new MyIdentity("Phil Guy", "Upline Guy", "IT Department");
            var cp = new ClaimsPrincipal(id);

            Thread.CurrentPrincipal = cp;
        }
Exemplo n.º 6
0
        private static bool ResolveIdentity(string name, out MyIdentity id)
        {
            long identityId;

            if (name.StartsWith("sid/", StringComparison.OrdinalIgnoreCase))
            {
                var num = ulong.Parse(name.Substring("sid/".Length));
                identityId = MySession.Static.Players.TryGetIdentityId(num);
            }
            else if (!long.TryParse(name, out identityId))
            {
                foreach (var p in MySession.Static.Players.GetAllPlayers())
                {
                    if (p.SerialId != 0)
                    {
                        continue;
                    }
                    var identity = MySession.Static.Players.TryGetPlayerIdentity(p);
                    if (identity == null)
                    {
                        continue;
                    }
                    if (!identity.DisplayName.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    id = identity;
                    return(true);
                }
            }

            id = MySession.Static.Players.TryGetIdentity(identityId);
            return(id != null);
        }
Exemplo n.º 7
0
        private void OnPlayersChanged(bool connected, MyPlayer.PlayerId pid)
        {
            MyIdentity identity = session.Players.TryGetPlayerIdentity(pid);

            ActivityCollector.Log.Info($"{identity.DisplayName} has {((connected) ? "Connected" : "Disconnected")}");
            if (connected)
            {
                MyPlayer p;
                session.Players.TryGetPlayerById(pid, out p);
                p.Controller.ControlledEntityChanged += OnControlledEntityChanged;

                SQLQueryData.WriteToDatabase(new UserDescription()
                {
                    SteamId   = pid.SteamId,
                    PlayerId  = identity.IdentityId,
                    Name      = identity.DisplayName,
                    Connected = Tools.DateTime,
                    State     = LoginState.Active
                });
            }
            else
            {
                SQLQueryData.WriteToDatabase(new UserDescription()
                {
                    SteamId      = pid.SteamId,
                    PlayerId     = identity.IdentityId,
                    Name         = identity.DisplayName,
                    Disconnected = Tools.DateTime,
                    State        = LoginState.Disconnected
                });
            }
        }
Exemplo n.º 8
0
        private static void LogIn(string strOperName, string strPWD, string strL6Name, string strL8Name)
        {
            if (!Membership.ValidateUser(strOperName, strPWD))
            {
                throw new BusinessException("登录错误", "操作员或密码输入错误");
            }


            SecurityManage security = new SecurityManage();
            Oper           oper     = security.GetOperByName(strOperName);
            Dept           dept     = new Dept();

            dept.cnnDeptID    = 0;
            dept.cnnDiscount  = 0;
            dept.cnvcDeptName = "云南人才中心";
            if (oper.cnnDeptID != 0)
            {
                dept = security.GetDeptById(oper.cnnDeptID);
            }

            List <string> lFunc       = security.GetFuncById(oper.cnnOperID, oper.cnnDeptID, constApp.strCardType, strL6Name, strL8Name);
            List <string> lAllFunc    = security.GetAllFunc(constApp.strCardType, strL6Name, strL8Name);
            MyIdentity    myidentity  = new MyIdentity(oper, dept, Membership.Provider.Name);
            MyPrincipal   myprincipal = new MyPrincipal(myidentity, lFunc, lAllFunc);

            Thread.CurrentPrincipal = myprincipal;
            //AppDomain.CurrentDomain.SetThreadPrincipal(myprincipal);
            //return security;
        }
Exemplo n.º 9
0
        private bool LoadShipBlueprint(MyObjectBuilder_ShipBlueprintDefinition shipBlueprint, Vector3D TargetLocation, bool keepOriginalLocation, Chat chat, Hangar Plugin, bool force = false)
        {
            var grids = shipBlueprint.CubeGrids;

            if (grids == null || grids.Length == 0)
            {
                chat.Respond("No grids in blueprint!");
                return(false);
            }

            try
            {
                MyIdentity IDentity = MySession.Static.Players.TryGetPlayerIdentity(new MyPlayer.PlayerId(SteamID));

                if (Plugin.GridBackup != null)
                {
                    Plugin.GridBackup.GetType().GetMethod("BackupGridsManuallyWithBuilders", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, new Type[2] {
                        typeof(List <MyObjectBuilder_CubeGrid>), typeof(long)
                    }, null).Invoke(Plugin.GridBackup, new object[] { grids.ToList(), IDentity.IdentityId });
                    Log.Warn("Successfully BackedUp grid!");
                }
            }
            catch (Exception e)
            {
                Log.Fatal(e);
            }

            //For loading in the same location



            ParallelSpawner Spawner = new ParallelSpawner(grids, chat);

            return(Spawner.Start(keepOriginalLocation, TargetLocation));
        }
        public void Restore(string playernameOrSteamId, string gridNameOrEntityId, int backupNumber = 1, bool keepOriginalPosition = false, bool force = false)
        {
            MyIdentity player = PlayerUtils.GetIdentityByNameOrId(playernameOrSteamId);

            if (player == null)
            {
                Context.Respond("Player not found!");
                return;
            }

            List <long> playerIdentityList = new List <long>();

            playerIdentityList.Add(player.IdentityId);

            var relevantGrids = Utilities.FindRelevantGrids(Plugin, playerIdentityList);

            Utilities.FindPathToRestore(Plugin, relevantGrids, gridNameOrEntityId, backupNumber,
                                        out string path, out bool gridFound, out bool outOfBounds);

            if (outOfBounds)
            {
                Context.Respond("Backup not found! Check if the number is in range!");
                return;
            }

            if (!gridFound)
            {
                Context.Respond("Grid not found!");
                return;
            }

            ImportPath(path, keepOriginalPosition, force);
        }
        private MyGps CreateGps(Vector3D location, MyIdentity identity)
        {
            var offset    = Plugin.Config.GpsOffsetFromPlayerKm;
            var offsetMax = Plugin.Config.GpsOffsetFromPlayerKmMax;

            if (offsetMax < offset)
            {
                offsetMax = offset;
            }

            if (offset > 0)
            {
                double distance    = offset * 1000.0;
                double distanceMax = offsetMax * 1000.0;

                location = FindRandomPosition(location, distance, distanceMax);
            }

            MyGps gps = new MyGps {
                Coords         = location,
                Name           = "Location of " + identity.DisplayName + " #" + DateTimeOffset.Now.ToUnixTimeMilliseconds(),
                DisplayName    = "Location of " + identity.DisplayName,
                Description    = "Bought via GPS Roulette plugin",
                GPSColor       = Color.Cyan,
                IsContainerGPS = true,
                ShowOnHud      = true,
                DiscardAt      = new TimeSpan?(),
                AlwaysVisible  = true
            };

            gps.UpdateHash();

            return(gps);
        }
Exemplo n.º 12
0
        public override void HandleResponse(JObject response)
        {
            if ((int)response["meta"]["next_check"] > 0)
            {
                Tebex.Instance.nextCheck = (int)response["meta"]["next_check"];
                //Tebex.Instance.nextCheck = 60;
            }

            if ((bool)response["meta"]["execute_offline"])
            {
                try
                {
                    TebexCommandRunner.doOfflineCommands();
                }
                catch (Exception e)
                {
                    Tebex.logError(e.ToString());
                }
            }

            JArray players = (JArray)response["players"];

            var onlinePlayers = MySession.Static.Players.GetOnlinePlayers();

            if (onlinePlayers.Count == 0)
            {
                return;
            }

            foreach (var player in players)
            {
                try
                {
                    ulong      steamId      = (ulong)player["uuid"];
                    long       identityId   = MySession.Static.Players.TryGetIdentityId(steamId);
                    MyIdentity targetPlayer = MySession.Static.Players.TryGetIdentity(identityId);

                    bool playerOnline = false;
                    foreach (var onlinePlr in onlinePlayers)
                    {
                        if (onlinePlr.Id.SteamId == steamId)
                        {
                            playerOnline = true;
                        }
                    }

                    if (playerOnline)
                    {
                        Tebex.logWarning("Execute commands for " + (string)targetPlayer.DisplayName + "(ID: " + steamId.ToString() + ")");
                        TebexCommandRunner.doOnlineCommands((int)player["id"], (string)targetPlayer.DisplayName,
                                                            steamId.ToString());
                    }
                }
                catch (Exception e)
                {
                    Tebex.logError(e.Message);
                }
            }
        }
Exemplo n.º 13
0
        public bool SaveGrids(List <MyCubeGrid> grids, string GridName, Hangar Plugin)
        {
            List <MyObjectBuilder_CubeGrid> objectBuilders = new List <MyObjectBuilder_CubeGrid>();

            foreach (MyCubeGrid grid in grids)
            {
                /* What else should it be? LOL? */
                if (!(grid.GetObjectBuilder() is MyObjectBuilder_CubeGrid objectBuilder))
                {
                    throw new ArgumentException(grid + " has a ObjectBuilder thats not for a CubeGrid");
                }

                objectBuilders.Add(objectBuilder);
            }



            try
            {
                MyIdentity IDentity = MySession.Static.Players.TryGetPlayerIdentity(new MyPlayer.PlayerId(SteamID));

                if (Plugin.GridBackup != null)
                {
                    Plugin.GridBackup.GetType().GetMethod("BackupGridsManuallyWithBuilders", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, new Type[2] {
                        typeof(List <MyObjectBuilder_CubeGrid>), typeof(long)
                    }, null).Invoke(Plugin.GridBackup, new object[] { objectBuilders, IDentity.IdentityId });
                    Log.Warn("Successfully BackedUp grid!");
                }
            }
            catch (Exception e)
            {
                Log.Fatal(e);
            }



            try
            {
                //Need To check grid name

                string GridSavePath = Path.Combine(FolderPath, GridName + ".sbc");

                //Log.Info("SavedDir: " + pathForPlayer);
                bool saved = SaveGridToFile(GridSavePath, GridName, objectBuilders);

                if (saved)
                {
                    DisposeGrids(grids);
                }


                return(saved);
            }
            catch (Exception e)
            {
                Hangar.Debug("Saving Grid Failed!", e, Hangar.ErrorType.Fatal);
                return(false);
            }
        }
Exemplo n.º 14
0
 public IdentityController(
     ILogger <IdentityController> logger,
     MyIdentity identity
     )
 {
     _logger   = logger;
     _identity = identity;
 }
        public void List(string playernameOrSteamId, string gridNameOrEntityId = null)
        {
            MyIdentity player = PlayerUtils.GetIdentityByNameOrId(playernameOrSteamId);

            if (player == null)
            {
                Context.Respond("Player not found!");
                return;
            }

            StringBuilder sb       = new StringBuilder();
            int           i        = 1;
            string        gridname = null;

            if (gridNameOrEntityId == null)
            {
                Utilities.AddListEntriesToSb(Plugin, sb, player.IdentityId, i, false, out _);
            }
            else
            {
                List <long> playerIdentityList = new List <long>();
                playerIdentityList.Add(player.IdentityId);

                var relevantGrids = Utilities.FindRelevantGrids(Plugin, playerIdentityList);

                Utilities.AddListEntriesToSb(relevantGrids, sb, gridNameOrEntityId, out gridname);

                if (gridname == null)
                {
                    Context.Respond("Grid not found!");
                    return;
                }
            }

            if (Context.Player == null)
            {
                Context.Respond($"Backed up Grids for Player {player.DisplayName} #{player.IdentityId}");

                if (gridname != null)
                {
                    Context.Respond($"Grid {gridname}");
                }

                Context.Respond(sb.ToString());
            }
            else
            {
                if (gridname != null)
                {
                    ModCommunication.SendMessageTo(new DialogMessage("Backed up Grids", $"Grid {gridname}", sb.ToString()), Context.Player.SteamUserId);
                }
                else
                {
                    ModCommunication.SendMessageTo(new DialogMessage("Backed up Grids", $"Player {player.DisplayName} #{player.IdentityId}", sb.ToString()), Context.Player.SteamUserId);
                }
            }
        }
Exemplo n.º 16
0
        bool CheckFactionStateChange(MyFactionStateChange action, long fromFactionId, long toFactionId, long playerId, long senderId)
        {
            Debug.Assert(Sync.IsServer, "Only server can check state of message!");
            if (!Sync.IsServer)
            {
                return(false);
            }

            if (!m_factions.ContainsKey(fromFactionId) || !m_factions.ContainsKey(toFactionId))
            {
                return(false);
            }

            var                        key = new MyFactionPair(fromFactionId, toFactionId);
            HashSet <long>             tmpSet;
            MyRelationsBetweenFactions tmp;

            switch (action)
            {
            case MyFactionStateChange.RemoveFaction: return(true);

            case MyFactionStateChange.SendPeaceRequest:   return((m_factionRequests.TryGetValue(fromFactionId, out tmpSet)) ? !tmpSet.Contains(toFactionId) : true);

            case MyFactionStateChange.CancelPeaceRequest: return((m_factionRequests.TryGetValue(fromFactionId, out tmpSet)) ?  tmpSet.Contains(toFactionId) : false);

            case MyFactionStateChange.AcceptPeace: return((m_relationsBetweenFactions.TryGetValue(key, out tmp)) ? tmp != MyRelationsBetweenFactions.Neutral : true);

            case MyFactionStateChange.DeclareWar:  return((m_relationsBetweenFactions.TryGetValue(key, out tmp)) ? tmp != MyRelationsBetweenFactions.Enemies : false);

            case MyFactionStateChange.FactionMemberSendJoin:   return(!m_factions[fromFactionId].IsMember(playerId) && !m_factions[fromFactionId].JoinRequests.ContainsKey(playerId));

            case MyFactionStateChange.FactionMemberCancelJoin: return(!m_factions[fromFactionId].IsMember(playerId) && m_factions[fromFactionId].JoinRequests.ContainsKey(playerId));

            case MyFactionStateChange.FactionMemberAcceptJoin: return(m_factions[fromFactionId].JoinRequests.ContainsKey(playerId));

            case MyFactionStateChange.FactionMemberKick:
                if (m_factions[fromFactionId].IsMember(playerId))
                {
                    if (MySession.Static.Settings.ScenarioEditMode && Sync.Players.IdentityIsNpc(playerId))
                    {
                        MyIdentity id = Sync.Players.TryGetIdentity(playerId);
                        id.TransferAllBlocksTo(senderId);
                    }
                    return(true);
                }
                return(false);

            case MyFactionStateChange.FactionMemberPromote:    return(m_factions[fromFactionId].IsMember(playerId));

            case MyFactionStateChange.FactionMemberDemote:     return(m_factions[fromFactionId].IsLeader(playerId));

            case MyFactionStateChange.FactionMemberLeave:      return(m_factions[fromFactionId].IsMember(playerId));
            }
            return(false);
        }
Exemplo n.º 17
0
        private bool PlayerIdentityLoop(Dictionary <long, Dictionary <string, int> > BlocksAndOwnerForLimits, int blocksToBuild)
        {
            foreach (KeyValuePair <long, Dictionary <string, int> > Player in BlocksAndOwnerForLimits)
            {
                Dictionary <string, int> PlayerBuiltBlocks = Player.Value;
                MyIdentity myIdentity = MySession.Static.Players.TryGetIdentity(Player.Key);
                if (myIdentity != null)
                {
                    MyBlockLimits blockLimits = myIdentity.BlockLimits;
                    if (MySession.Static.BlockLimitsEnabled == MyBlockLimitsEnabledEnum.PER_FACTION && MySession.Static.Factions.GetPlayerFaction(myIdentity.IdentityId) == null)
                    {
                        Chat.Respond("ServerLimits are set PerFaction. You are not in a faction! Contact an Admin!");
                        return(false);
                    }

                    if (blockLimits != null)
                    {
                        if (MySession.Static.MaxBlocksPerPlayer != 0 && blockLimits.BlocksBuilt + blocksToBuild > blockLimits.MaxBlocks)
                        {
                            Chat.Respond("Cannot load grid! You would be over your Max Blocks!");
                            return(false);
                        }

                        //Double check to see if the list is null
                        if (PlayerBuiltBlocks != null)
                        {
                            foreach (KeyValuePair <string, short> ServerBlockLimits in MySession.Static.BlockTypeLimits)
                            {
                                if (PlayerBuiltBlocks.ContainsKey(ServerBlockLimits.Key))
                                {
                                    int TotalNumberOfBlocks = PlayerBuiltBlocks[ServerBlockLimits.Key];

                                    if (blockLimits.BlockTypeBuilt.TryGetValue(ServerBlockLimits.Key, out MyBlockLimits.MyTypeLimitData LimitData))
                                    {
                                        //Grab their existing block count for the block limit
                                        TotalNumberOfBlocks += LimitData.BlocksBuilt;
                                    }

                                    //Compare to see if they would be over!
                                    short ServerLimit = MySession.Static.GetBlockTypeLimit(ServerBlockLimits.Key);
                                    if (TotalNumberOfBlocks > ServerLimit)
                                    {
                                        Chat.Respond("Player " + myIdentity.DisplayName + " would be over their " + ServerBlockLimits.Key + " limits! " + TotalNumberOfBlocks + "/" + ServerLimit);
                                        //Player would be over their block type limits
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
Exemplo n.º 18
0
        private static bool RemoveFromFaction_Internal(MyIdentity identity)
        {
            var fac = MySession.Static.Factions.GetPlayerFaction(identity.IdentityId);

            if (fac == null)
            {
                return(false);
            }
            fac.KickMember(identity.IdentityId);
            return(true);
        }
Exemplo n.º 19
0
        public static string GetPlayerNameById(long playerId)
        {
            MyIdentity identity = GetIdentityById(playerId);

            if (identity != null)
            {
                return(identity.DisplayName);
            }

            return("Nobody");
        }
Exemplo n.º 20
0
        void CreatingPrincipalAndIdentity(WindowsIdentity windowsIdentity) // Noncompliant, IIdentity parameter, see another section with tests
        {
            IIdentity identity;

            identity = new MyIdentity();        // Noncompliant, creation of type that implements IIdentity
//                     ^^^^^^^^^^^^^^^^
            identity = new WindowsIdentity(""); // Noncompliant
            IPrincipal principal;

            principal = new MyPrincipal();                     // Noncompliant, creation of type that implements IPrincipal
            principal = new WindowsPrincipal(windowsIdentity); // Noncompliant
        }
Exemplo n.º 21
0
        void OpenRequest(bool open, long identityId)
        {
            VRage.Game.MyRelationsBetweenPlayerAndBlock relation = GetUserRelationToOwner(identityId);

            MyIdentity identity = MySession.Static.Players.TryGetIdentity(identityId);
            MyPlayer   player   = identity != null && identity.Character != null?MyPlayer.GetPlayerFromCharacter(identity.Character) : null;

            if (relation.IsFriendly() ||
                (identity != null && identity.Character != null && player != null && MySession.Static.IsUserSpaceMaster(player.Client.SteamUserId)))
            {
                Open = open;
            }
        }
Exemplo n.º 22
0
 public void BuyShip(int key, long BuyerId)
 {
     if (items.ContainsKey(key))
     {
         MarketItem item     = items[key];
         MyIdentity SellerId = AlliancePlugin.TryGetIdentity(item.SellerSteamId.ToString());
         if (SellerId != null)
         {
             EconUtils.addMoney(SellerId.IdentityId, item.Price);
             EconUtils.takeMoney(BuyerId, item.Price);
         }
     }
 }
Exemplo n.º 23
0
        public void CanSerializeIdentity()
        {
            // Arrange
            MyIdentity id1 = BuildId();

            // Act
            byte[]     data = Serializer.Serialize(id1);
            MyIdentity id2  = (MyIdentity)Serializer.Deserialize(data);

            // Assert
            Assert.IsNotNull(id2);
            Assert.AreEqual(id1, id2);
        }
Exemplo n.º 24
0
        public static string GetOwner(this IMyCubeGrid grid)
        {
            if (grid.BigOwners.Count > 0 && grid.BigOwners[0] > 0)
            {
                MyIdentity ownerIdentity = MySession.Static.Players.TryGetIdentity(grid.BigOwners[0]);

                if (ownerIdentity != null)
                {
                    return(ownerIdentity.DisplayName);
                }
            }
            return("");
        }
Exemplo n.º 25
0
        protected void Application_PostAuthenticateRequest()
        {
            HttpCookie authoCookies = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authoCookies != null)
            {
                FormsAuthenticationTicket ticket   = FormsAuthentication.Decrypt(authoCookies.Value);
                JavaScriptSerializer      js       = new JavaScriptSerializer();
                User                   user        = js.Deserialize <User>(ticket.UserData);
                MyIdentity             myIdentity  = new MyIdentity(user);
                MyIdentity.MyPrincipal myPrincipal = new MyIdentity.MyPrincipal(myIdentity);
                HttpContext.Current.User = myPrincipal;
            }
        }
        private CheckResult FixGroups(ConcurrentBag<MyGroups<MyCubeGrid, MyGridPhysicalGroupData>.Group> groups, long playerId) {

            var result = CheckGroups(groups, out MyGroups<MyCubeGrid, MyGridPhysicalGroupData>.Group group, playerId, FactionFixEnabled);

            if (result != CheckResult.OK)
                return result;

            MyIdentity executingPlayer = null;

            if (playerId != 0)
                executingPlayer = PlayerUtils.GetIdentityById(playerId);

            return FixGroup(group, executingPlayer);
        }
Exemplo n.º 27
0
        protected void Application_PostAuthenticateRequest()
        {
            var cockie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (cockie != null)
            {
                var ticket    = FormsAuthentication.Decrypt(cockie.Value);
                var js        = new JavaScriptSerializer();
                var user      = js.Deserialize <MyUser>(ticket.UserData);
                var identity  = new MyIdentity(user);
                var principal = new MyPrincipal(identity);
                HttpContext.Current.User = principal;
            }
        }
Exemplo n.º 28
0
        public static DateTime GetLastSeenDate(MyIdentity identity)
        {
            var lastLogoutTime = identity.LastLogoutTime;
            var lastLoginTime  = identity.LastLoginTime;

            var date = lastLogoutTime;

            if (lastLoginTime > lastLogoutTime)
            {
                date = lastLoginTime;
            }

            return(date);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Получение сущности игрока в мире игры по имени
 /// </summary>
 /// <param name="playerName">Имя игрока</param>
 /// <returns></returns>
 public static MyIdentity GetIdentityByName(string playerName)
 {
     using (IEnumerator <MyIdentity> enumerator = ((IEnumerable <MyIdentity>)((MyPlayerCollection)MySession.Static.Players).GetAllIdentities()).GetEnumerator())
     {
         while (((IEnumerator)enumerator).MoveNext())
         {
             MyIdentity current = enumerator.Current;
             if (current.DisplayName == playerName)
             {
                 return(current);
             }
         }
     }
     return((MyIdentity)null);
 }
        private void ShowPlayerNotOnlineMessage(MyIdentity identity)
        {
            var messageBox = MyGuiSandbox.CreateMessageBox(
                buttonType: MyMessageBoxButtonsType.OK,
                messageText: new StringBuilder().AppendFormat(MyCommonTexts.MessageBoxTextPlayerNotOnline, identity.DisplayName),
                messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                canHideOthers: false,
                callback: (result) =>
            {
                RecreateControls();
            }
                );

            MyGuiSandbox.AddScreen(messageBox);
        }