public static bool Read( NetState State, string Name, string Password, out Account Acc ) { Acc = new Account(); Acc.Netstate = State; ResultTable table = Core.Database.Query( "SELECT * FROM accounts WHERE name = '{0}' AND password = '******' LIMIT 0,1", Name.MysqlEscape(), Password.MysqlEscape() ); table.TableName = "Account Table"; if( table.Rows.Count == 0 ) return false; ResultRow row = table[ 0 ]; Acc.Serial = new Serial( row[ "account_id" ].GetInt(), ESerialType.Account ); Acc.Name = row[ "name" ].GetString(); Acc.Password = row[ "password" ].GetString(); Acc.LastIP = row[ "last_ip" ].GetString(); Acc.LastLogin = row[ "last_login" ].GetInt(); Acc.Email = row[ "email" ].GetString(); Acc.UpdateLastLogin(); table = Core.Database.Query( "SELECT * FROM chars WHERE account_id = {0}", Acc.Serial.Value ); table.TableName = "Char Table"; if( table.Rows.Count == 0 ) return true; Character c; while( ( row = table.GetNext() ) != null ) { c = new Character( Acc, row[ "char_id" ].GetInt(), row[ "name" ].GetString() ); Acc.Chars.Add( c.Serial, c ); } return true; }
public Character( Account Parent, int ID, string Name ) { mParent = Parent; Serial = Serial.NewChar; mName = Name; }