public void Process(Context context) { if (Nickname.Length > MAX_LENGTH) { Nickname = Nickname.Substring(0, MAX_LENGTH); } context.Server.Database.UpdateNickname(context.User, Nickname); var updatedFriendsList = new FriendsList(context.User); context.Server.Database.QueryFriends(context.User).ForEach(friend => { var friendSession = context.Server.GetSession(friend); if (friendSession != null) { friendSession.SendAndProcessMessage(updatedFriendsList); } }); }
public PK6 convertToPK6() { PK6 pk6 = new PK6 // Convert away! { EncryptionConstant = PID, Species = Species, TID = TID, SID = SID, EXP = EXP, PID = PID, Ability = Ability }; int[] abilities = PersonalInfo.Abilities; int abilval = Array.IndexOf(abilities, Ability); if (abilval >= 0) { pk6.AbilityNumber = 1 << abilval; } else // Fallback (shouldn't happen) { if (HiddenAbility) { pk6.AbilityNumber = 4; // Hidden, else G5 or G3/4 correlation. } else { pk6.AbilityNumber = Gen5 ? 1 << (int)(PID >> 16 & 1) : 1 << (int)(PID & 1); } } pk6.Markings = Markings; pk6.Language = Language; pk6.CNT_Cool = CNT_Cool; pk6.CNT_Beauty = CNT_Beauty; pk6.CNT_Cute = CNT_Cute; pk6.CNT_Smart = CNT_Smart; pk6.CNT_Tough = CNT_Tough; // Cap EVs pk6.EV_HP = EV_HP > 252 ? 252 : EV_HP; pk6.EV_ATK = EV_ATK > 252 ? 252 : EV_ATK; pk6.EV_DEF = EV_DEF > 252 ? 252 : EV_DEF; pk6.EV_SPA = EV_SPA > 252 ? 252 : EV_SPA; pk6.EV_SPD = EV_SPD > 252 ? 252 : EV_SPD; pk6.EV_SPE = EV_SPE > 252 ? 252 : EV_SPE; pk6.Move1 = Move1; pk6.Move2 = Move2; pk6.Move3 = Move3; pk6.Move4 = Move4; pk6.Move1_PPUps = Move1_PPUps; pk6.Move2_PPUps = Move2_PPUps; pk6.Move3_PPUps = Move3_PPUps; pk6.Move4_PPUps = Move4_PPUps; // Fix PP pk6.Move1_PP = pk6.getMovePP(pk6.Move1, pk6.Move1_PPUps); pk6.Move2_PP = pk6.getMovePP(pk6.Move2, pk6.Move2_PPUps); pk6.Move3_PP = pk6.getMovePP(pk6.Move3, pk6.Move3_PPUps); pk6.Move4_PP = pk6.getMovePP(pk6.Move4, pk6.Move4_PPUps); pk6.IV_HP = IV_HP; pk6.IV_ATK = IV_ATK; pk6.IV_DEF = IV_DEF; pk6.IV_SPA = IV_SPA; pk6.IV_SPD = IV_SPD; pk6.IV_SPE = IV_SPE; pk6.IsEgg = IsEgg; pk6.IsNicknamed = IsNicknamed; pk6.FatefulEncounter = FatefulEncounter; pk6.Gender = Gender; pk6.AltForm = AltForm; pk6.Nature = Nature; pk6.Nickname = Nickname.Length > 1 && !IsNicknamed ? Nickname[0] + Nickname.Substring(1).ToLower() // Decapitalize : Nickname; pk6.Version = Version; pk6.OT_Name = OT_Name; // Dates are kept upon transfer pk6.MetDate = MetDate; pk6.EggMetDate = EggMetDate; // Locations are kept upon transfer pk6.Met_Location = Met_Location; pk6.Egg_Location = Egg_Location; pk6.PKRS_Strain = PKRS_Strain; pk6.PKRS_Days = PKRS_Days; pk6.Ball = Ball; // OT Gender & Encounter Level pk6.Met_Level = Met_Level; pk6.OT_Gender = OT_Gender; pk6.EncounterType = EncounterType; // Ribbon Decomposer (Contest & Battle) byte contestribbons = 0; byte battleribbons = 0; // Contest Ribbon Counter for (int i = 0; i < 8; i++) // Sinnoh 3, Hoenn 1 { if ((Data[0x60] >> i & 1) == 1) { contestribbons++; } if (((Data[0x61] >> i) & 1) == 1) { contestribbons++; } if (((Data[0x3C] >> i) & 1) == 1) { contestribbons++; } if (((Data[0x3D] >> i) & 1) == 1) { contestribbons++; } } for (int i = 0; i < 4; i++) // Sinnoh 4, Hoenn 2 { if (((Data[0x62] >> i) & 1) == 1) { contestribbons++; } if (((Data[0x3E] >> i) & 1) == 1) { contestribbons++; } } // Battle Ribbon Counter // Winning Ribbon if ((Data[0x3E] & 0x20) >> 5 == 1) { battleribbons++; } // Victory Ribbon if ((Data[0x3E] & 0x40) >> 6 == 1) { battleribbons++; } for (int i = 1; i < 7; i++) // Sinnoh Battle Ribbons { if (((Data[0x24] >> i) & 1) == 1) { battleribbons++; } } // Fill the Ribbon Counter Bytes pk6.RibbonCountMemoryContest = contestribbons; pk6.RibbonCountMemoryBattle = battleribbons; // Copy Ribbons to their new locations. int bx30 = 0; // bx30 |= 0; // Kalos Champ - New Kalos Ribbon bx30 |= ((Data[0x3E] & 0x10) >> 4) << 1; // Hoenn Champion bx30 |= ((Data[0x24] & 0x01) >> 0) << 2; // Sinnoh Champ // bx30 |= 0; // Best Friend - New Kalos Ribbon // bx30 |= 0; // Training - New Kalos Ribbon // bx30 |= 0; // Skillful - New Kalos Ribbon // bx30 |= 0; // Expert - New Kalos Ribbon bx30 |= ((Data[0x3F] & 0x01) >> 0) << 7; // Effort Ribbon pk6.Data[0x30] = (byte)bx30; int bx31 = 0; bx31 |= ((Data[0x24] & 0x80) >> 7) << 0; // Alert bx31 |= ((Data[0x25] & 0x01) >> 0) << 1; // Shock bx31 |= ((Data[0x25] & 0x02) >> 1) << 2; // Downcast bx31 |= ((Data[0x25] & 0x04) >> 2) << 3; // Careless bx31 |= ((Data[0x25] & 0x08) >> 3) << 4; // Relax bx31 |= ((Data[0x25] & 0x10) >> 4) << 5; // Snooze bx31 |= ((Data[0x25] & 0x20) >> 5) << 6; // Smile bx31 |= ((Data[0x25] & 0x40) >> 6) << 7; // Gorgeous pk6.Data[0x31] = (byte)bx31; int bx32 = 0; bx32 |= ((Data[0x25] & 0x80) >> 7) << 0; // Royal bx32 |= ((Data[0x26] & 0x01) >> 0) << 1; // Gorgeous Royal bx32 |= ((Data[0x3E] & 0x80) >> 7) << 2; // Artist bx32 |= ((Data[0x26] & 0x02) >> 1) << 3; // Footprint bx32 |= ((Data[0x26] & 0x04) >> 2) << 4; // Record bx32 |= ((Data[0x26] & 0x10) >> 4) << 5; // Legend bx32 |= ((Data[0x3F] & 0x10) >> 4) << 6; // Country bx32 |= ((Data[0x3F] & 0x20) >> 5) << 7; // National pk6.Data[0x32] = (byte)bx32; int bx33 = 0; bx33 |= ((Data[0x3F] & 0x40) >> 6) << 0; // Earth bx33 |= ((Data[0x3F] & 0x80) >> 7) << 1; // World bx33 |= ((Data[0x27] & 0x04) >> 2) << 2; // Classic bx33 |= ((Data[0x27] & 0x08) >> 3) << 3; // Premier bx33 |= ((Data[0x26] & 0x08) >> 3) << 4; // Event bx33 |= ((Data[0x26] & 0x40) >> 6) << 5; // Birthday bx33 |= ((Data[0x26] & 0x80) >> 7) << 6; // Special bx33 |= ((Data[0x27] & 0x01) >> 0) << 7; // Souvenir pk6.Data[0x33] = (byte)bx33; int bx34 = 0; bx34 |= ((Data[0x27] & 0x02) >> 1) << 0; // Wishing Ribbon bx34 |= ((Data[0x3F] & 0x02) >> 1) << 1; // Battle Champion bx34 |= ((Data[0x3F] & 0x04) >> 2) << 2; // Regional Champion bx34 |= ((Data[0x3F] & 0x08) >> 3) << 3; // National Champion bx34 |= ((Data[0x26] & 0x20) >> 5) << 4; // World Champion pk6.Data[0x34] = (byte)bx34; // Write Transfer Location - location is dependent on 3DS system that transfers. pk6.Country = PKMConverter.Country; pk6.Region = PKMConverter.Region; pk6.ConsoleRegion = PKMConverter.ConsoleRegion; // Write the Memories, Friendship, and Origin! pk6.CurrentHandler = 1; pk6.HT_Name = PKMConverter.OT_Name; pk6.HT_Gender = PKMConverter.OT_Gender; pk6.Geo1_Region = PKMConverter.Region; pk6.Geo1_Country = PKMConverter.Country; pk6.HT_Intensity = 1; pk6.HT_Memory = 4; pk6.HT_Feeling = (int)(Util.rnd32() % 10); // When transferred, friendship gets reset. pk6.OT_Friendship = pk6.HT_Friendship = PersonalInfo.BaseFriendship; // Antishiny Mechanism ushort LID = (ushort)(PID & 0xFFFF); ushort HID = (ushort)(PID >> 0x10); int XOR = TID ^ SID ^ LID ^ HID; if (XOR >= 8 && XOR < 16) // If we get an illegal collision... { pk6.PID ^= 0x80000000; } // HMs are not deleted 5->6, transfer away (but fix if blank spots?) pk6.FixMoves(); // Decapitalize if (!pk6.IsNicknamed && pk6.Nickname.Length > 1) { pk6.Nickname = char.ToUpper(pk6.Nickname[0]) + pk6.Nickname.Substring(1).ToLower(); } // Fix Name Strings pk6.Nickname = pk6.Nickname .Replace('\u2467', '\u00d7') // × .Replace('\u2468', '\u00f7') // ÷ .Replace('\u246c', '\u2026') // … .Replace('\u246d', '\uE08E') // ♂ .Replace('\u246e', '\uE08F') // ♀ .Replace('\u246f', '\uE090') // ♠ .Replace('\u2470', '\uE091') // ♣ .Replace('\u2471', '\uE092') // ♥ .Replace('\u2472', '\uE093') // ♦ .Replace('\u2473', '\uE094') // ★ .Replace('\u2474', '\uE095') // ◎ .Replace('\u2475', '\uE096') // ○ .Replace('\u2476', '\uE097') // □ .Replace('\u2477', '\uE098') // △ .Replace('\u2478', '\uE099') // ◇ .Replace('\u2479', '\uE09A') // ♪ .Replace('\u247a', '\uE09B') // ☀ .Replace('\u247b', '\uE09C') // ☁ .Replace('\u247d', '\uE09D') // ☂ ; pk6.OT_Name = pk6.OT_Name .Replace('\u2467', '\u00d7') // × .Replace('\u2468', '\u00f7') // ÷ .Replace('\u246c', '\u2026') // … .Replace('\u246d', '\uE08E') // ♂ .Replace('\u246e', '\uE08F') // ♀ .Replace('\u246f', '\uE090') // ♠ .Replace('\u2470', '\uE091') // ♣ .Replace('\u2471', '\uE092') // ♥ .Replace('\u2472', '\uE093') // ♦ .Replace('\u2473', '\uE094') // ★ .Replace('\u2474', '\uE095') // ◎ .Replace('\u2475', '\uE096') // ○ .Replace('\u2476', '\uE097') // □ .Replace('\u2477', '\uE098') // △ .Replace('\u2478', '\uE099') // ◇ .Replace('\u2479', '\uE09A') // ♪ .Replace('\u247a', '\uE09B') // ☀ .Replace('\u247b', '\uE09C') // ☁ .Replace('\u247d', '\uE09D') // ☂ ; // Fix Checksum pk6.RefreshChecksum(); return(pk6); // Done! }
public void Load() { if (this.ID == 0) { this.LoginName = "Guest"; this.PasswordHash = ""; this.Nickname = ""; this.BirthDay = ""; this.Email = ""; this.FirstName = ""; this.LastName = ""; this.StreetAddress = ""; this.State = ""; this.City = ""; this.Country = ""; this.VerificationHash = ""; this.Notes = ""; this.MemberData = ""; this.SecurityQuestion = ""; this.SecurityAnswer = ""; this.PIN = "0000"; this.ID = 0; this.ZIP = 0; this.Authority = 0; this.Cash = 0; this.EmailVerified = false; this.RequestSecure = false; this.GlobalSession = false; this.IsValid = false; return; } MySqlCommand MemberLoadQuery = new MySqlCommand("SELECT * FROM members WHERE ID=@ID", SqlConnection); MemberLoadQuery.Parameters.AddWithValue("@ID", this.ID); while (Executing) { System.Threading.Thread.Sleep(10); } Executing = true; using (MySqlDataReader MemberLoadReader = MemberLoadQuery.ExecuteReader(System.Data.CommandBehavior.SingleRow)) { if (MemberLoadReader.Read()) { this.LoginName = MemberLoadReader.GetString("LoginName"); this.PasswordHash = MemberLoadReader.GetString("PasswordHash"); this.Nickname = MemberLoadReader.GetString("Nickname"); this.BirthDay = MemberLoadReader.GetString("BirthDay"); this.Email = MemberLoadReader.GetString("Email"); this.FirstName = MemberLoadReader.GetString("FirstName"); this.LastName = MemberLoadReader.GetString("LastName"); this.StreetAddress = MemberLoadReader.GetString("StreetAddress"); this.State = MemberLoadReader.GetString("State"); this.City = MemberLoadReader.GetString("City"); this.Country = MemberLoadReader.GetString("Country"); this.VerificationHash = MemberLoadReader.GetString("VerificationHash"); this.Notes = MemberLoadReader.GetString("Notes"); this.MemberData = MemberLoadReader.GetString("MemberData"); this.SecurityQuestion = MemberLoadReader.GetString("SecurityQuestion"); this.SecurityAnswer = MemberLoadReader.GetString("SecurityAnswer"); this.PIN = MemberLoadReader.GetString("PIN"); this.NameFontColor = MemberLoadReader.GetString("NameFontColor"); this.StatusFontColor = MemberLoadReader.GetString("StatusFontColor"); this.ID = MemberLoadReader.GetInt32("ID"); this.ZIP = MemberLoadReader.GetInt32("ZIP"); this.Authority = MemberLoadReader.GetInt32("Authority"); this.Cash = MemberLoadReader.GetInt32("Cash"); this.LinkedDevices.AddRange(MemberLoadReader.GetString("LinkedDevices").Split(',')); this.PendingFriends.AddRange(MemberLoadReader.GetString("PendingFriends").Split(',')); this.BlockedFriends.AddRange(MemberLoadReader.GetString("BlockedFriends").Split(',')); this.Friends.AddRange(MemberLoadReader.GetString("Friends").Split(',')); this.EmailVerified = MemberLoadReader.GetBoolean("EmailVerified"); this.RequestSecure = MemberLoadReader.GetBoolean("RequestSecure"); this.GlobalSession = MemberLoadReader.GetBoolean("GlobalSession"); this.MobileNotifications = MemberLoadReader.GetBoolean("MobileNotifications"); this.EmailNotifications = MemberLoadReader.GetBoolean("EmailNotifications"); this.IsPremiumIM = MemberLoadReader.GetBoolean("IsPremiumIM"); this.IsValid = true; Nickname = char.ToUpper(Nickname[0]) + Nickname.Substring(1); FirstName = char.ToUpper(FirstName[0]) + FirstName.Substring(1); LastName = char.ToUpper(LastName[0]) + LastName.Substring(1); } else { this.LoginName = "Guest"; this.PasswordHash = ""; this.Nickname = ""; this.BirthDay = ""; this.Email = ""; this.FirstName = ""; this.LastName = ""; this.StreetAddress = ""; this.State = ""; this.City = ""; this.Country = ""; this.VerificationHash = ""; this.Notes = ""; this.MemberData = ""; this.SecurityQuestion = ""; this.SecurityAnswer = ""; this.PIN = "0000"; this.ID = 0; this.ZIP = 0; this.Authority = 0; this.Cash = 0; this.EmailVerified = false; this.RequestSecure = false; this.GlobalSession = false; this.IsValid = false; } } Executing = false; }