Example #1
0
        // There are top lists, race lists, and class lists.  By passing the actual
        // list
        public static void SortFraglist( CharData ch, FragData[] list )
        {
            FragData person = new FragData();
            FragData temp = new FragData();
            int count;
            bool found = false;

            if( ch.IsNPC() )
            {
                Log.Error( "Mobile in Fraglist.SortFraglist(), check frag code!", 0 );
                return;
            }

            for( count = 0; count < FraglistData.MAX_FRAG; ++count )
            {
                if( list[ count ].Name.Equals(ch.Name, StringComparison.CurrentCultureIgnoreCase ) )
                {
                    // remove them from the list if they're in it already
                    list[ count ].Name = String.Empty;
                    list[ count ].Frags = 0;
                    found = true;
                }
            }

            // Shift a blank entry to the bottom of the list
            if( found )
            {
                for( count = 0; count < FraglistData.MAX_FRAG; ++count )
                {
                    if( list[ count ].Name.Length < 1 && count < ( FraglistData.MAX_FRAG - 1 ) )
                    {
                        list[ count ].Name = list[ count + 1 ].Name;
                        list[ count ].Frags = list[ count + 1 ].Frags;
                        list[ count + 1 ].Name = String.Empty;
                        list[ count + 1 ].Frags = 0;
                    }
                }
            }

            person.Name = ch.Name;
            person.Frags = ( (PC)ch ).Frags;

            // This works fine provided a blank entry isn't found where the player
            // used to be.  If a blank entry is found it'll plug in the data and continue
            // without setting the _name.
            for( count = 0; count < FraglistData.MAX_FRAG; ++count )
            {
                // Use absolute value so we can handle the negative frags properly too
                if( ( Math.Abs( list[ count ].Frags ) > Math.Abs( person.Frags ) ) )
                    continue;

                temp.Name = list[ count ].Name;
                temp.Frags = list[ count ].Frags;

                list[ count ].Name = String.Empty;
                list[ count ].Name = person.Name;
                list[ count ].Frags = person.Frags;

                person.Name = temp.Name;
                person.Frags = temp.Frags;
                temp.Name = String.Empty;

            }

            // See if the ch or victim qualify to replace an entry in either list.
            // damn hard code to write.
        }
Example #2
0
        // There are top lists, race lists, and class lists.  By passing the actual
        // list
        static public void SortFraglist(CharData ch, FragData[] list)
        {
            FragData person = new FragData();
            FragData temp   = new FragData();
            int      count;
            bool     found = false;

            if (ch.IsNPC())
            {
                Log.Error("Mobile in Fraglist.SortFraglist(), check frag code!", 0);
                return;
            }

            for (count = 0; count < FraglistData.MAX_FRAG; ++count)
            {
                if (list[count].Name.Equals(ch.Name, StringComparison.CurrentCultureIgnoreCase))
                {
                    // remove them from the list if they're in it already
                    list[count].Name  = String.Empty;
                    list[count].Frags = 0;
                    found             = true;
                }
            }

            // Shift a blank entry to the bottom of the list
            if (found)
            {
                for (count = 0; count < FraglistData.MAX_FRAG; ++count)
                {
                    if (list[count].Name.Length < 1 && count < (FraglistData.MAX_FRAG - 1))
                    {
                        list[count].Name      = list[count + 1].Name;
                        list[count].Frags     = list[count + 1].Frags;
                        list[count + 1].Name  = String.Empty;
                        list[count + 1].Frags = 0;
                    }
                }
            }

            person.Name  = ch.Name;
            person.Frags = ((PC)ch).Frags;

            // This works fine provided a blank entry isn't found where the player
            // used to be.  If a blank entry is found it'll plug in the data and continue
            // without setting the _name.
            for (count = 0; count < FraglistData.MAX_FRAG; ++count)
            {
                // Use absolute value so we can handle the negative frags properly too
                if ((Math.Abs(list[count].Frags) > Math.Abs(person.Frags)))
                {
                    continue;
                }

                temp.Name  = list[count].Name;
                temp.Frags = list[count].Frags;

                list[count].Name  = String.Empty;
                list[count].Name  = person.Name;
                list[count].Frags = person.Frags;

                person.Name  = temp.Name;
                person.Frags = temp.Frags;
                temp.Name    = String.Empty;
            }

            // See if the ch or victim qualify to replace an entry in either list.
            // damn hard code to write.
        }