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 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 CharacterSelect(NetState state, PacketReader reader) { short slot = reader.ReadByte(); if (state.Account == null || state.Account.AccountState != EAccountState.Char) { state.Send(new CharacterResponseError((byte)0)); state.Disconnect(); return; } if (state.Account.HasSlot(slot) == false) { state.Send(new CharacterResponseError((byte)0)); state.Disconnect(); return; } Character selectedChar = state.Account.SetActiveChar(slot); state.Send(new CharacterResponseWorldLogin(selectedChar)); }
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)); }
/// Request to walk /// 0x00A7 9: public static void WalkToXY(NetState state, PacketReader reader) { if (state.IsValid(EAccountState.World) == false) { state.Disconnect(); return; } Character c = state.Account.ActiveChar; int unkInt = reader.ReadInt32(); // Since 2008-08-27aRagexeRE, X/Y starts at pos 6 byte b1 = reader.ReadByte(); byte b2 = reader.ReadByte(); byte b3 = reader.ReadByte(); int x = b1 * 4 + (b2 >> 6); int y = ((b2 & 0x3f) << 4) + (b3 >> 4); Point2D targetLoc = new Point2D(x, y); c.TargetLocation = c.Location.Point + (c.Location.Point - targetLoc); }