public static void CharacterCreation(NetState state, PacketReader reader) { if (state.Account == null || state.Account.AccountState != EAccountState.Char) { state.Disconnect(); return; } string name = reader.ReadString(24); byte attrStr = reader.ReadByte(); byte attrAgi = reader.ReadByte(); byte attrVit = reader.ReadByte(); byte attrInt = reader.ReadByte(); byte attrDex = reader.ReadByte(); byte attrLuk = reader.ReadByte(); byte slot = reader.ReadByte(); short hairColor = reader.ReadInt16(); short hairStyle = reader.ReadInt16(); Character newChar = null; ECharacterCreationResult result = Character.Create(state.Account, name, slot, attrStr, attrAgi, attrVit, attrInt, attrDex, attrLuk, hairColor, hairStyle, out newChar); if (result != ECharacterCreationResult.Success) { state.Send(new CharacterResponseCreation(result)); return; } // Creation was successfull, send new characterlist state.Send(new CharacterResponseNewData(newChar)); }
public static void AccountAuth(NetState state, PacketReader reader) { int accountID = reader.ReadInt32(); int loginID1 = reader.ReadInt32(); int loginID2 = reader.ReadInt32(); int unknown = reader.ReadInt16(); // offset 14 - 16 int iSex = reader.ReadByte(); EAccountSex sex = (EAccountSex)iSex; state.Account = (Account)World.Objects[EDatabaseType.Account, accountID]; state.Account.Netstate = state; if ( state.Account == null || state.Account.AccountState != EAccountState.Login || state.Account.LoginID1 != loginID1 || state.Account.LoginID2 != loginID2 || state.Account.Sex != sex ) { // Wrong data - hack attempt? state.Account = null; state.Send(new CharacterResponseError((byte)0)); return; } // Mark as authed in character server state.Account.AccountState = EAccountState.Char; state.Account.LoadChars(); // Auth successfull, send a special packet containing the AccountID state.Send(new CharacterResponseSuccess(state.Account)); // Send character list state.Send(new CharacterResponseList(state.Account)); }
/// <summary> /// <para>ID 0x0436</para> /// <para>Length 19</para> /// <para>First packet after selecting a character</para> /// </summary> public static void WantToConnect(NetState state, PacketReader reader) { int accountID = reader.ReadInt32(); int charID = reader.ReadInt32(); int loginID1 = reader.ReadInt32(); int clientTick = reader.ReadInt32(); byte iSex = reader.ReadByte(); EAccountSex sex = (EAccountSex)iSex; state.Account = World.GetAccount(accountID); if (state.Account == null || state.Account.AccountState != EAccountState.Char) { state.Disconnect(); return; } if (state.Account.LoginID1 != loginID1 || state.Account.Sex != sex) { state.Disconnect(); return; } if (state.Account.ActiveChar == null || state.Account.ActiveChar.ID != charID) { state.Disconnect(); return; } // Mark as authed state.Account.AccountState = EAccountState.World; state.Send(new Response.WorldAuthOK(state.Account)); }
public static void AccountLogin(NetState state, PacketReader reader) { int clientVersion = reader.ReadInt32(); string loginName = reader.ReadString(24); string loginPassword = reader.ReadString(24); byte clientType = reader.ReadByte(); Account acc; EAccountLoadResult result = Account.Load(state, loginName, loginPassword, out acc, false); if (result != EAccountLoadResult.Success) { state.Send(new Response.LoginResponseAccountError((byte)result)); state.Disconnect(); return; } acc.AccountState = EAccountState.Login; acc.UpdateLastLogin(state.Address.ToString()); state.Send(new Response.LoginResponseServerList(acc)); }
public static void CharacterSelect(NetState state, PacketReader reader) { short slot = reader.ReadByte(); if (state.Account == null || state.Account.AccountState != EAccountState.Char) { state.Send(new Response.CharacterResponseError((byte)0)); state.Disconnect(); return; } if (state.Account.HasSlot(slot) == false) { state.Send(new Response.CharacterResponseError((byte)0)); state.Disconnect(); return; } Character selectedChar = state.Account.SetActiveChar(slot); state.Send(new Response.CharacterWorldLogin(selectedChar)); }
/// Request for game exiting /// 018A 4: <dont_know>.W public static void QuitGame(NetState state, PacketReader reader) { if (state.IsValid(EAccountState.World) == false) { state.Disconnect(); return; } // TODO: logout check state.Send(new Response.WorldConfirmGameExit(true)); }