Example #1
0
 private void UpdateThreatFromHealer(Transform healer, float healingValue)
 {
     if (CharacterUtilities.GetFaction(healer) != _faction)
     {
         UpdateThreat(healer, healingValue * PcHealingThreatModifier);
     }
 }
        private void AddSymbolsToProduction(Production prod, List <string> list)
        {
            // Version 1.3.1 sends even empty lists to this method.
            // Furthermore, version 1.3.1 no longer explicitly calls
            // FixInternalReduction().  It is easier to adopt a consistent
            // approach and let AddXxxToProd check for a trailing action
            // prior to adding symbols or a new action.
            //
            if (list != null)
            {
                if (prod.semanticAction != null || prod.precSpan != null)
                {
                    FixInternalReduction(prod);
                }
                foreach (string str in list)
                {
                    Symbol symbol = null;

                    switch (TokenOf(str))
                    {
                    case Token.litchar:     // This is a character literal symbol
                        if (GPCG.ImportedTokens && Terminal.BumpsMax(str))
                        {
                            handler.ListError(this.CurrentLocationSpan, 82, str, '\0');
                        }
                        symbol = grammar.LookupTerminal(Token.litchar, str);
                        break;

                    case Token.litstring:     // This is a uned occurrence of a terminal alias.
                        String s = CharacterUtilities.CanonicalizeAlias(str);
                        if (!grammar.aliasTerms.ContainsKey(s))
                        {
                            handler.ListError(this.CurrentLocationSpan, 83, str, '\0');
                        }
                        else
                        {
                            symbol = grammar.aliasTerms[s];
                            if (symbol == Terminal.Ambiguous)     // Use of an ambiguous alias.
                            {
                                handler.ListError(this.CurrentLocationSpan, 84, str, '\0');
                            }
                        }
                        break;

                    case Token.ident:     // This is a used occurrence of a terminal name.
                        if (grammar.terminals.ContainsKey(str))
                        {
                            symbol = grammar.terminals[str];
                        }
                        else
                        {
                            symbol = grammar.LookupNonTerminal(str);
                        }
                        break;
                    }
                    prod.rhs.Add(symbol);
                }
            }
        }
        private void SpawnedGridsSuccessful(HashSet <MyCubeGrid> Grids)
        {
            GridUtilities.BiggestGrid(Grids, out MyCubeGrid BiggestGrid);

            if (BiggestGrid != null && IdentityID != 0)
            {
                CharacterUtilities.SendGps(BiggestGrid.PositionComp.GetPosition(), BiggestGrid.DisplayName, IdentityID);
            }
        }
 private void HandleOtherSelectionWhenActive(Transform selection)
 {
     if ((!CharacterUtilities.CharacterTargetsAllies(Transform)) && (!CharacterUtilities.CharactersAreAllies(Transform, selection)))
     {
         Debug.Log(Transform.name + ": targets HOSTILES - setting target to " + selection.name);
         _statusEventDispatcher.FireStatusEvent(selection, StatusMessage.EnemyActionTargetSelected);
         _statusEventDispatcher.FireStatusEvent(selection, StatusMessage.CharacterDeactivated);
     }
 }
Example #5
0
        internal static string GetVerbatimString(LexSpan span)
        {
            string text = span.ToString();

            if (text[0] != '@' || text[1] != '\"' || text[text.Length - 1] != '\"')
            {
                throw new GppgInternalException("Internal error: invalid litstring");
            }
            text = text.Substring(2, text.Length - 3);
            return(CharacterUtilities.InterpretEscapesInVerbatimString(text));
        }
        private void AttemptTargetAssignment(Transform requestingNpc)
        {
            List <Transform> targetList   = CharacterUtilities.CharacterTargetsAllies(requestingNpc) ? _allies : _enemies;
            Transform        actionTarget = SelectTarget(targetList, requestingNpc);

            if ((actionTarget != null) && (TargetAssignmentHandler != null))
            {
                Debug.Log("Assigning target " + actionTarget.name + " to " + requestingNpc.name);
                TargetAssignmentHandler(requestingNpc, actionTarget);
            }
        }
 private void HandleButtonEvent(string buttonName, bool isPressed)
 {
     if (SceneMovementButton.Movement_Buttons.Contains(buttonName))
     {
         _blockAction = isPressed;
         _fieldMovementController.IgnoreFieldClickEvents = isPressed;
         if (!CharacterUtilities.CharacterTargetsAllies(_transform))
         {
             _autoActionController.AutoActionDisabled = true;
         }
     }
 }
Example #8
0
        private bool HasKeyword()
        {
            return(Grammar.Keywords.Keys.Any(k =>
            {
                if (k == null)
                {
                    throw new ArgumentNullException(nameof(k));
                }
                var p1 = _source.ElementAtOrDefault(_currentCharOffset + k.Length);

                return !CharacterUtilities.IsDigitLetterOrUnderscore(p1) &&
                string.Equals(PeekMany(k.Length), k, StringComparison.InvariantCultureIgnoreCase);
            }));
        }
 private void HandleSelfSelection()
 {
     if (CharacterUtilities.CharacterTargetsAllies(_currentActiveCharacter))
     {
         Debug.Log(_currentActiveCharacter.name + ": targets FRIENDLIES - setting target to " + Transform.name);
         _statusEventDispatcher.FireStatusEvent(_currentActiveCharacter, StatusMessage.AlliedActionTargetSelected);
         _statusEventDispatcher.FireStatusEvent(_currentActiveCharacter, StatusMessage.CharacterDeactivated);
     }
     else
     {
         Debug.Log(Transform.name + " was set to active");
         _currentActiveCharacter = Transform;
         _statusEventDispatcher.FireStatusEvent(StatusMessage.CharacterActivated);
     }
 }
Example #10
0
        internal string GetLitString(LexSpan span)
        {
            string text = span.ToString();

            if (text[0] != '\"' || text[text.Length - 1] != '\"')
            {
                throw new GppgInternalException("Internal error: invalid litstring");
            }
            text = text.Substring(1, text.Length - 2);
            try
            {
                text = CharacterUtilities.InterpretCharacterEscapes(text);
            }
            catch (StringInterpretException e)
            {
                handler.ListError(span, 70, e.Message, '\'');
            }
            return(text);
        }
        private bool CheckDistanceToLoadPoint(Vector3D LoadPoint)
        {
            if (!Config.RequireLoadRadius)
            {
                return(true);
            }


            double Distance = Vector3D.Distance(PlayerPosition, LoadPoint);

            if (Distance < Config.LoadRadius)
            {
                return(true);
            }

            CharacterUtilities.SendGps(LoadPoint, "Load Point", IdentityID);
            Chat.Respond("Cannot load! You are " + Math.Round(Distance, 0) + "m away from the load point! Check your GPS points!");
            return(false);
        }
Example #12
0
        private SyntaxNode Scan()
        {
            _state = (SafePeekChar(), SafePeekCharP1()) switch
            {
                var(c1, _) when c1.HasValue&& CharacterUtilities.IsWhitespace(c1.Value) => ScannerState.Whitespace,
                ('<', _) => ScannerState.Html,
                ('/', '/') => ScannerState.LineComment,
                ('/', '*') => ScannerState.BlockComment,
                ('#', _) => ScannerState.Preprocessor,

                var(c1, c2) when c1.HasValue &&
                c2.HasValue &&
                Grammar.Punctuation.ContainsKey($"{c1.Value}{c2.Value}") =>
                ScannerState.Punctuation2,

                var(c1, _) when c1.HasValue&& Grammar.Punctuation.ContainsKey($"{c1.Value}") => ScannerState
                .Punctuation1,

                ('"', _) => ScannerState.String,
                var(c1, _) when c1.HasValue&& char.IsDigit(c1.Value) => ScannerState.Number,
                ('.', var c2)when c2.HasValue && char.IsDigit(c2.Value) => ScannerState.Number,
                ('-', var c2)when c2.HasValue && (char.IsDigit(c2.Value) || c2.Value == '.') => ScannerState.Number,

                var(c1, _) when c1.HasValue&& char.IsLetter(c1.Value) => HasKeyword()
                    ? ScannerState.Keyword
                    : ScannerState.Id,

                var(c1, _) when c1.HasValue&& CharacterUtilities.IsDigitLetterOrUnderscore(c1.Value) => ScannerState
                .Id,

                _ => ScannerState.Nothing
            };

            if (_state == ScannerState.Nothing)
            {
                return(null);
            }
            NextNode();
            return(_currentNode);
        }
Example #13
0
        private SyntaxTrivia ScanWhitespace()
        {
            var start = _currentCharOffset;

            _scratch.Clear();

            while (true)
            {
                if (Empty())
                {
                    break;
                }
                var c = CurrentChar;
                if (!CharacterUtilities.IsWhitespace(c))
                {
                    break;
                }
                _scratch.Append(c);
                NextChar();
            }

            return(new SyntaxTrivia(SyntaxKind.WhitespaceTrivia, start, _currentCharOffset - start, _scratch.ToString()));
        }
Example #14
0
        private SyntaxToken ScanId()
        {
            _scratch.Clear();

            var start = _currentCharOffset;

            if (!char.IsLetter(CurrentChar) && CurrentChar != '_')
            {
                throw GetException($"Expecting letter or _, found {CurrentChar}.");
            }

            _scratch.Append(CurrentChar);
            NextChar();

            while (true)
            {
                if (Empty())
                {
                    break;
                }
                var c = CurrentChar;

                if (CharacterUtilities.IsDigitLetterOrUnderscore(c))
                {
                    _scratch.Append(c);
                }
                else
                {
                    break;
                }

                NextChar();
            }

            return(new StringSyntax(SyntaxKind.IdToken, start, _currentCharOffset - start, _scratch.ToString()));
        }
Example #15
0
        private static int Main(string[] args)
        {
            args = new[] { "/report", "/verbose", "/conflicts", "/babel", "SpecFiles\\BrightScript.y" };
            Stream inputFile = null;

            Grammar      grammar       = null;
            ErrorHandler handler       = new ErrorHandler();
            string       inputFileInfo = null; // Filename plus revision time.
            Scanner      scanner       = null;
            Parser       parser        = null;
            Assembly     assm          = Assembly.GetExecutingAssembly();
            object       info          = Attribute.GetCustomAttribute(assm, typeof(AssemblyFileVersionAttribute));

            versionInfo = ((AssemblyFileVersionAttribute)info).Version;

            try {
                string filename = ProcessOptions(args);

                if (filename == null)
                {
                    return(MC_OK);
                }

                try {
                    inputFile     = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
                    inputFileInfo = filename + " - " + File.GetLastWriteTime(filename).ToString();
                }
                catch (IOException x) {
                    string message;
                    inputFile = null;
                    if (x is FileNotFoundException)
                    {
                        message = String.Format(CultureInfo.InvariantCulture,
                                                "Source file <{0}> not found{1}",
                                                filename, Environment.NewLine);
                    }
                    else
                    {
                        message = String.Format(CultureInfo.InvariantCulture,
                                                "Source file <{0}> could not be opened{1}",
                                                filename, Environment.NewLine);
                    }
                    handler.AddError(4, message, null);   // aast.AtStart;
                    return(MC_FILEERROR);
                }

                scanner = new Scanner(inputFile);
                scanner.SetHandler(handler);

                parser = new Parser(filename, inputFileInfo, scanner, handler);
                //
                // If the parse is successful, then process the grammar.
                // Otherwise just report the errors that have been listed.
                //
                if (parser.Parse() && !handler.Errors)
                {
                    grammar = parser.Grammar;

                    if (Terminal.Max > 255)
                    {
                        // No ambiguating context possible since result appears in delimited error message
                        handler.ListError(null, 103, CharacterUtilities.MapCodepointToDisplayForm(Terminal.Max), '\'');
                    }

                    LALRGenerator         generator = new LALRGenerator(grammar);
                    List <AutomatonState> states    = generator.BuildStates();
                    generator.ComputeLookAhead();
                    generator.BuildParseTable();
                    if (!grammar.CheckGrammar())
                    {
                        throw new ArgumentException("Non-terminating grammar");
                    }
                    //
                    // If the grammar has non-terminating non-terms we cannot
                    // create a diagnostic report as the grammar is incomplete.
                    //
                    if (!handler.Errors)
                    {
                        CodeGenerator emitter = new CodeGenerator(grammar);
                        emitter.Generate(states);
                    }

                    bool DoDiagnose = Diagnose && !grammar.HasNonTerminatingNonTerms;
                    if (Report || DoDiagnose)
                    {
                        string htmlName = System.IO.Path.ChangeExtension(filename, ".report.html");
                        try {
                            System.IO.FileStream   htmlFile   = new System.IO.FileStream(htmlName, System.IO.FileMode.Create);
                            System.IO.StreamWriter htmlWriter = new System.IO.StreamWriter(htmlFile);
                            Grammar.HtmlHeader(htmlWriter, filename);

                            if (Report && DoDiagnose)
                            {
                                grammar.GenerateCompoundReport(htmlWriter, inputFileInfo, states);
                            }
                            else if (Report)
                            {
                                grammar.GenerateReport(htmlWriter, inputFileInfo, states);
                            }

                            Grammar.HtmlTrailer(htmlWriter);

                            if (htmlFile != null)
                            {
                                htmlWriter.Flush();
                                htmlFile.Close();
                            }
                        }
                        catch (System.IO.IOException) {
                            Console.Error.WriteLine("Cannot create html output file {0}", htmlName);
                        }
                    }
                }
            }
            catch (System.Exception e) {
                if (e is TooManyErrorsException)
                {
                    return(MC_TOOMANYERRORS);
                }
                Console.Error.WriteLine("Unexpected Error {0}", e.Message);

                if (NoThrowOnError)
                {
                    // report the error, do not let it go into the void
                    Console.Error.WriteLine(e);
                    return(MC_EXCEPTION);
                }
            }
            finally {
                if (handler.Errors || handler.Warnings)
                {
                    handler.DumpAll((scanner == null ? null : scanner.Buffer), Console.Error);
                }
                if ((Listing || handler.Errors || handler.Warnings) && parser != null)
                {
                    string       listName   = parser.ListfileName;
                    StreamWriter listStream = ListingFile(listName);
                    if (listStream != null)
                    {
                        handler.MakeListing(scanner.Buffer, listStream, parser.SourceFileInfo, versionInfo);
                    }
                }

                Console.WriteLine("Press any enter to close");
                Console.ReadLine();
            }
            return(MC_OK);
        }
        private bool CheckEnemyDistance(LoadType LoadingAtSavePoint, Vector3D Position = new Vector3D())
        {
            if (LoadingAtSavePoint == LoadType.ForceLoadMearPlayer)
            {
                Position = PlayerPosition;
            }

            MyFaction PlayersFaction = MySession.Static.Factions.GetPlayerFaction(IdentityID);
            bool      EnemyFoundFlag = false;

            if (Config.DistanceCheck > 0)
            {
                //Check enemy location! If under limit return!
                foreach (MyCharacter OnlinePlayer in MyEntities.GetEntities().OfType <MyCharacter>())
                {
                    if (OnlinePlayer == null || OnlinePlayer.MarkedForClose)
                    {
                        continue;
                    }

                    long PlayerID = OnlinePlayer.GetPlayerIdentityId();
                    if (PlayerID == 0L)
                    {
                        continue;
                    }
                    if (PlayerID == IdentityID)
                    {
                        continue;
                    }



                    MyFaction TargetPlayerFaction = MySession.Static.Factions.GetPlayerFaction(PlayerID);
                    if (PlayersFaction != null && TargetPlayerFaction != null)
                    {
                        if (PlayersFaction.FactionId == TargetPlayerFaction.FactionId)
                        {
                            continue;
                        }

                        //Neutrals count as allies not friends for some reason
                        MyRelationsBetweenFactions Relation = MySession.Static.Factions.GetRelationBetweenFactions(PlayersFaction.FactionId, TargetPlayerFaction.FactionId).Item1;
                        if (Relation == MyRelationsBetweenFactions.Neutral || Relation == MyRelationsBetweenFactions.Friends)
                        {
                            continue;
                        }
                    }

                    if (Vector3D.Distance(Position, OnlinePlayer.PositionComp.GetPosition()) == 0)
                    {
                        continue;
                    }

                    if (Vector3D.Distance(Position, OnlinePlayer.PositionComp.GetPosition()) <= Config.DistanceCheck)
                    {
                        Chat?.Respond("Unable to load grid! Enemy within " + Config.DistanceCheck + "m!");
                        CharacterUtilities.SendGps(Position, "Failed Hangar Load! (Enemy nearby)", IdentityID);
                        EnemyFoundFlag = true;
                        break;
                    }
                }
            }


            if (Config.GridDistanceCheck > 0 && Config.GridCheckMinBlock > 0 && EnemyFoundFlag == false)
            {
                BoundingSphereD SpawnSphere = new BoundingSphereD(Position, Config.GridDistanceCheck);

                List <MyEntity> entities = new List <MyEntity>();
                MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref SpawnSphere, entities);



                //This is looping through all grids in the specified range. If we find an enemy, we need to break and return/deny spawning
                foreach (MyCubeGrid Grid in entities.OfType <MyCubeGrid>())
                {
                    if (Grid == null || Grid.MarkedForClose)
                    {
                        continue;
                    }

                    if (Grid.BigOwners.Count <= 0 || Grid.CubeBlocks.Count < Config.GridCheckMinBlock)
                    {
                        continue;
                    }

                    if (Grid.BigOwners.Contains(IdentityID))
                    {
                        continue;
                    }



                    //if the player isnt big owner, we need to scan for faction mates
                    bool FoundAlly = true;
                    foreach (long Owner in Grid.BigOwners)
                    {
                        MyFaction TargetPlayerFaction = MySession.Static.Factions.GetPlayerFaction(Owner);
                        if (PlayersFaction != null && TargetPlayerFaction != null)
                        {
                            if (PlayersFaction.FactionId == TargetPlayerFaction.FactionId)
                            {
                                continue;
                            }

                            MyRelationsBetweenFactions Relation = MySession.Static.Factions.GetRelationBetweenFactions(PlayersFaction.FactionId, TargetPlayerFaction.FactionId).Item1;
                            if (Relation == MyRelationsBetweenFactions.Enemies)
                            {
                                FoundAlly = false;
                                break;
                            }
                        }
                        else
                        {
                            FoundAlly = false;
                            break;
                        }
                    }


                    if (!FoundAlly)
                    {
                        //Stop loop
                        Chat?.Respond("Unable to load grid! Enemy within " + Config.GridDistanceCheck + "m!");
                        CharacterUtilities.SendGps(Position, "Failed Hangar Load! (Enemy nearby)", IdentityID);
                        EnemyFoundFlag = true;
                        break;
                    }
                }
            }
            return(!EnemyFoundFlag);
        }
Example #17
0
            /// <summary>
            /// Create a transition path in the NFSA from the given
            /// start state to the given end state, corresponding to the
            /// RegEx tree value.  The method may (almost always does)
            /// create new NFSA states and recurses to make paths for
            /// the subtrees of the given tree.
            /// </summary>
            /// <param name="tree">The tree to encode</param>
            /// <param name="start">The start state for the pattern</param>
            /// <param name="end">The end state for the pattern</param>
            internal void MakePath(RegExTree tree, NState startState, NState endState)
            {
                NState tmp1 = null;

                switch (tree.op)
                {
                case RegOp.eof:
                    break;

                // Binary nodes ===================================
                case RegOp.context:
                case RegOp.concat:
                case RegOp.alt:
                    // Binary nodes ===================================
                    Binary binNode = tree as Binary;
                    switch (tree.op)
                    {
                    case RegOp.context:
                        int rLen = binNode.rKid.contextLength();
                        int lLen = binNode.lKid.contextLength();
                        if (rLen <= 0 && lLen <= 0)
                        {
                            throw new StringInterpretException("variable right context '/' not implemented");
                        }
                        else
                        {
                            endState.rhCntx = rLen;
                            endState.lhCntx = lLen;
                            tmp1            = MkState();
                            MakePath(binNode.lKid, startState, tmp1);
                            MakePath(binNode.rKid, tmp1, endState);
                        }
                        break;

                    case RegOp.concat:
                        tmp1 = MkState();
                        MakePath(binNode.lKid, startState, tmp1);
                        MakePath(binNode.rKid, tmp1, endState);
                        break;

                    case RegOp.alt:
                        tmp1 = MkState();
                        MakePath(binNode.lKid, startState, tmp1);
                        tmp1.AddEpsTrns(endState);
                        tmp1 = MkState();
                        MakePath(binNode.rKid, startState, tmp1);
                        tmp1.AddEpsTrns(endState);
                        break;
                    }
                    break;

                // Unary nodes ===================================
                case RegOp.closure:
                case RegOp.finiteRep:
                    // Unary nodes ===================================
                    Unary unaryNode = tree as Unary;
                    switch (tree.op)
                    {
                    case RegOp.closure:
                        NState tmp2 = MkState();
                        if (unaryNode.minRep == 0)
                        {
                            tmp1 = MkState();
                            startState.AddEpsTrns(tmp1);
                        }
                        else
                        {
                            NState dummy = startState;
                            for (int i = 0; i < unaryNode.minRep; i++)
                            {
                                tmp1 = MkState();
                                MakePath(unaryNode.kid, dummy, tmp1);
                                dummy = tmp1;
                            }
                        }
                        MakePath(unaryNode.kid, tmp1, tmp2);
                        tmp2.AddEpsTrns(tmp1);
                        tmp1.AddEpsTrns(endState);
                        break;

                    case RegOp.finiteRep:
                    {
                        NState dummy = tmp1 = startState;
                        for (int i = 0; i < unaryNode.minRep; i++)
                        {
                            tmp1 = MkState();
                            MakePath(unaryNode.kid, dummy, tmp1);
                            dummy = tmp1;
                        }
                        tmp1.AddEpsTrns(endState);
                        for (int i = unaryNode.minRep; i < unaryNode.maxRep; i++)
                        {
                            tmp1 = MkState();
                            MakePath(unaryNode.kid, dummy, tmp1);
                            dummy = tmp1;
                            dummy.AddEpsTrns(endState);
                        }
                    }
                    break;
                    }
                    break;

                // Leaf nodes ===================================
                case RegOp.litStr:
                case RegOp.primitive:
                case RegOp.charClass:
                    // Leaf nodes ===================================
                    Leaf leafNode = tree as Leaf;
                    switch (tree.op)
                    {
                    case RegOp.litStr:
                    {
                        // Make a linear sequence of states with successive
                        // transitions on successive string characters.
                        //
                        string text  = leafNode.str;
                        NState dummy = startState;
                        // Need to deal with special case of empty string
                        if (text.Length == 0)
                        {
                            dummy.AddEpsTrns(endState);
                        }
                        else
                        {
                            //  This code is complicated by the fact that unicode
                            //  escape substitution may have inserted surrogate
                            //  pairs of characters in the string.  We need
                            //  one transition for every unicode codepoint,
                            //  not one for every char value in this string.
                            //
                            int index = 0;
                            int code  = CharacterUtilities.CodePoint(text, ref index);            // First character
                            int next  = CharacterUtilities.CodePoint(text, ref index);            // Next, possibly -1
                            while (next >= 0)
                            {
                                tmp1 = MkState();
                                dummy.AddChrTrns(code, tmp1);
                                dummy = tmp1;
                                code  = next;
                                next  = CharacterUtilities.CodePoint(text, ref index);
                            }
                            // Postcondition ==> "code" is the last char.
                            dummy.AddChrTrns(code, endState);
                        }
                    }
                    break;

                    case RegOp.primitive:
                        startState.AddChrTrns(leafNode.chVal, endState);
                        break;

                    case RegOp.charClass:
                        startState.AddClsTrans(leafNode, endState);
                        break;
                    }
                    break;

                default: throw new GplexInternalException("unknown tree op");
                }
            }
        private bool CheckZoneRestrictions(bool IsSave)
        {
            if (Config.ZoneRestrictions.Count != 0)
            {
                //Get save point
                int    ClosestPoint = -1;
                double Distance     = -1;

                for (int i = 0; i < Config.ZoneRestrictions.Count(); i++)
                {
                    Vector3D ZoneCenter = new Vector3D(Config.ZoneRestrictions[i].X, Config.ZoneRestrictions[i].Y, Config.ZoneRestrictions[i].Z);

                    double PlayerDistance = Vector3D.Distance(ZoneCenter, PlayerPosition);

                    if (PlayerDistance <= Config.ZoneRestrictions[i].Radius)
                    {
                        //if player is within range

                        if (IsSave && !Config.ZoneRestrictions[i].AllowSaving)
                        {
                            Chat?.Respond("You are not permitted to save grids in this zone");
                            return(false);
                        }

                        if (!IsSave && !Config.ZoneRestrictions[i].AllowLoading)
                        {
                            Chat?.Respond("You are not permitted to load grids in this zone");
                            return(false);
                        }
                        return(true);
                    }



                    if (IsSave && Config.ZoneRestrictions[i].AllowSaving)
                    {
                        if (ClosestPoint == -1 || PlayerDistance <= Distance)
                        {
                            ClosestPoint = i;
                            Distance     = PlayerDistance;
                        }
                    }


                    if (!IsSave && Config.ZoneRestrictions[i].AllowLoading)
                    {
                        if (ClosestPoint == -1 || PlayerDistance <= Distance)
                        {
                            ClosestPoint = i;
                            Distance     = PlayerDistance;
                        }
                    }
                }
                Vector3D ClosestZone = new Vector3D();
                try
                {
                    ClosestZone = new Vector3D(Config.ZoneRestrictions[ClosestPoint].X, Config.ZoneRestrictions[ClosestPoint].Y, Config.ZoneRestrictions[ClosestPoint].Z);
                }
                catch (Exception e)
                {
                    Chat?.Respond("No areas found!");
                    //Log.Warn(e, "No suitable zones found! (Possible Error)");
                    return(false);
                }



                if (IsSave)
                {
                    CharacterUtilities.SendGps(ClosestZone, Config.ZoneRestrictions[ClosestPoint].Name + " (within " + Config.ZoneRestrictions[ClosestPoint].Radius + "m)", IdentityID);
                    Chat?.Respond("Nearest save area has been added to your HUD");
                    return(false);
                }
                else
                {
                    CharacterUtilities.SendGps(ClosestZone, Config.ZoneRestrictions[ClosestPoint].Name + " (within " + Config.ZoneRestrictions[ClosestPoint].Radius + "m)", IdentityID);
                    //Chat chat = new Chat(Context);
                    Chat?.Respond("Nearest load area has been added to your HUD");
                    return(false);
                }
            }
            return(true);
        }