예제 #1
0
파일: Account.cs 프로젝트: karliky/wowwow
        //not a static !!!
        /// <summary> 
        /// Create xmlnode from all elements of Account record 
        /// </summary> 
        /// <param name="doc">recursive reference for creating node</param> 
        /// <returns>xmlnode with all info about acc</returns> 
        public XmlNode Save( XmlFile doc )
        {
            //current version=1 (Core.Accounts.version)
                XmlNode result = doc.CreateNode( "account", "" );
                doc.AddAttribute( result, xml_attr_username, username );
                doc.AddAttribute( result, xml_attr_password, password );
                doc.AddAttribute( result, xml_attr_accesslevel, ((int)accessLevel).ToString() );

                foreach ( Character ch in characteres )                        //{+} Added
                {
                    UInt64 guid = ch.Guid;
                    doc.AddNode( result, xml_attr_guid, guid.ToString() );
                }

                return result;
        }
예제 #2
0
파일: Accounts.cs 프로젝트: karliky/wowwow
        public void Save( string filename )
        {
            XmlFile file = new XmlFile( false, "", "accounts" );
            int version = 0;
            file.AddAttribute( file.DocumentElement, "version", version.ToString() );//adding version of accountlist

            foreach ( Account acc in this )
            {
                file.DocumentElement.AppendChild( acc.Save( file ) );
            }

            file.Save( filename );
        }
예제 #3
0
파일: Account.cs 프로젝트: karliky/wowwow
 /// <summary> 
 /// Create new Account, Load all info for acc from xml node 
 /// </summary> 
 /// <param name="version">version for loading</param> 
 /// <param name="node">load from</param> 
 /// <param name="doc">recursive reference for checking</param> 
 /// <returns>Loaded Account</returns> 
 public Account( int version, XmlNode node, XmlFile doc )
 {
     if ( version == 1 )
         {
             username      = doc.GetAttributeVal( node, xml_attr_username, null );
             password      = doc.GetAttributeVal( node, xml_attr_password, null );
             accessLevel   = (AccessLevels)Convert.ToInt32( doc.GetAttributeVal( node, xml_attr_accesslevel, "0" ) );
             foreach ( XmlNode char_node in node.SelectNodes( xml_attr_guid ) )
             {
                 UInt64 guid = UInt64.Parse( doc.GetInnerText( char_node, "0" ) );
                 Character character = (Character)World.FindMobileByGUID( guid );
                 if ( character != null )
                 {
                     characteres.Add( character );
                     if ( World.StandardServer )
                         World.allMobiles.Remove( character );
                 }
             }
         }
 }
예제 #4
0
파일: Accounts.cs 프로젝트: karliky/wowwow
        /// <summary> 
        /// Load all accounts from xml file 
        /// </summary> 
        /// <param name="filename">file with accounts</param> 
        /// <returns></returns> 
        public void Load( string filename )
        {
            if ( System.IO.File.Exists( filename ) )
            {
                XmlFile file = new XmlFile( filename );

                int ver = 1;//readed version, for compatibility (new account list)

                if ( file.DocumentElement.Attributes["version"]!= null )
                {
                    try { ver = Convert.ToInt32(file.DocumentElement.Attributes["version"]); }
                    catch { ver = 1; }
                    // need corrections, maybe wrong file or bad records? .. etc
                }

                foreach ( XmlNode node in file.DocumentElement.SelectNodes( "account" ) )
                {
                    Account acc = new Account( ver, node, file );
                    if ( acc != null )
                        List.Add( acc );
                }
            }
            if ( Count == 0 )
            {
                Account admin = new Account( "admin", "changeme", AccessLevels.Admin );
                Add( admin );
            }
        }