private static void ParseRequestToPlayerInfo(GPCMClient client, Dictionary <string, string> recv, ref uint partnerID) { if (recv.ContainsKey("partnerid")) { partnerID = Convert.ToUInt32(recv["partnerid"]); //partnerID = 0; } // Parse the 3 login types information if (recv.ContainsKey("uniquenick")) { client.PlayerInfo.PlayerUniqueNick = recv["uniquenick"]; } else if (recv.ContainsKey("authtoken")) { client.PlayerInfo.PlayerAuthToken = recv["authtoken"]; } else if (recv.ContainsKey("user")) { // "User" is <nickname>@<email> //string user = recv["user"]; //int Pos = user.IndexOf('@'); ////we add the nick and email to dictionary //string nick = user.Substring(0, Pos); //string email = user.Substring(Pos + 1); //recv.Add("nick", nick); //recv.Add("email", email); client.PlayerInfo.PlayerNick = recv["nick"]; client.PlayerInfo.PlayerEmail = recv["email"]; } }
//public static GPCMDBQuery DBQuery = null; public static void AddFriends(GPCMClient client, Dictionary <string, string> recv) { GPErrorCode error = IsContainAllKeys(recv); if (error != GPErrorCode.NoError) { GameSpyLib.Common.GameSpyUtils.SendGPError(client, error, "Parsing error in request"); } }
/// <summary> /// Polls the connection, and checks for drops /// </summary> public static void SendKeepAlive(GPCMClient client) { if (client.PlayerInfo.LoginStatus == LoginStatus.Completed) { // Try and send a Keep-Alive try { client.Send(@"\ka\\final\"); } catch { client.DisconnectByReason(DisconnectReason.KeepAliveFailed); } } }
public static void HandleSendBuddies(GPCMClient client, Dictionary <string, string> recv) { // \bdy\<number of friends>\list\<array of profileids>\ //TODO //total number of friends // we have to separate friends by productid,namespaceid,partnerid,gamename //because you will have different friends in different game if (client.BuddiesSent) { return; } /*Stream.SendAsync( * @"\bdy\1\list\2,\final\"); * * Stream.SendAsync( * // @"\bm\100\f\2\msg\|s|0|ss|Offline\final\" * @"\bm\100\f\2\msg\Messaggio di prova|s|2|ss|Home|ls|locstr://Reversing the world...|\final\" * );*/ client.Send(@"\bdy\1\list\13\final\"); client.Send(@"\bm\100\f\13\msg\|s|0|ss|Offline\final\"); client.Send(@"\bm\100\f\13\msg\1|signed|1"); return; int[] pids = SendBuddiesQuery.GetProfileidArray(recv); int numBuddies = pids.Length; client.BuddiesSent = true; string sendingBuffer; string profileidArray = ""; for (int i = 0; i < numBuddies; i++) { profileidArray += pids[i].ToString(); } sendingBuffer = string.Format(@"\bdy\{0}\list\{1}\final\", numBuddies, profileidArray); client.Send(sendingBuffer); }
/// <summary> /// Creates an account and use new account to login /// </summary> /// <param name="client">The client that sended the data</param> /// <param name="dict">The request that the stream sended</param> public static void NewUser(GPCMClient client, Dictionary <string, string> dict) { //Format the password for our database storage GPErrorCode error = IsRequestContainAllKeys(dict); //if there do not recieved right <key,value> pairs we send error if (error != GPErrorCode.NoError) { GameSpyUtils.SendGPError(client, error, "Error recieving request. Please check the input!"); return; } //Check the nick and uniquenick is formated correct and uniquenick is existed in database string sendingBuffer; error = IsEmailNickUniquenickValied(dict); if (error != GPErrorCode.NoError) { sendingBuffer = string.Format(@"\nur\{0}\final\", (int)error); client.Send(sendingBuffer); return; } //if the request did not contain uniquenick and namespaceid we use our way to create it. PreProcessRequest(dict); //we get the userid in database. If no userid found according to email we create one //and store the new account into database. int profileid = CreateAccount(dict); if (profileid == -1) { GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, "Account is existed, please use another one."); } else { sendingBuffer = string.Format(@"\nur\0\pid\{0}\final\", profileid); client.Send(sendingBuffer); } }
/// <summary> /// update the uniquenick /// </summary> /// <param name="client"></param> /// <param name="dict"></param> public static void RegisterNick(GPCMClient client, Dictionary <string, string> dict) { GPErrorCode error = IsContainAllKeys(dict); if (error != GPErrorCode.NoError) { GameSpyUtils.SendGPError(client, error, "Parsing error"); return; } string sendingBuffer; try { RegisterNickQuery.UpdateUniquenick(dict); sendingBuffer = @"\rn\final\"; client.Send(sendingBuffer); } catch (Exception e) { LogWriter.Log.WriteException(e); } }
public static void UpdateStatus(GPCMClient client, Dictionary <string, string> recv, GPCMStatusChanged OnStatusChanged) { //TODO ushort testSK; if (!recv.ContainsKey("statstring") || !recv.ContainsKey("locstring") || !recv.ContainsKey("sesskey")) { return; } if (!ushort.TryParse(recv["sesskey"], out testSK)) { return; // Invalid session key } if (testSK != client.SessionKey) { return; // Are you trying to update another user? } client.PlayerInfo.PlayerStatusString = recv["statstring"]; client.PlayerInfo.PlayerLocation = recv["locstring"]; OnStatusChanged?.Invoke(client); }
public static void Addfriends(GPCMClient client, Dictionary <string, string> recv) { GameSpyUtils.PrintReceivedGPDictToLogger("profilelist", recv); GameSpyUtils.SendGPError(client, GPErrorCode.General, "This request is not supported yet."); }
public static void Handle(GPCMClient client, Dictionary <string, string> recv) { }
/// <summary> /// Updates profiles /// </summary> /// <param name="recv">Array of information sent by the server</param> public static void UpdateUser(GPCMClient client, Dictionary <string, string> recv) { // Set clients country code if (!recv.ContainsKey("sesskey")) { return; } ushort ssk; if (!ushort.TryParse(recv["sesskey"], out ssk)) { return; } if (ssk != client.SessionKey) { return; } string query = "UPDATE profiles SET"; object[] passData = new object[22] { null, // publicmask : 0 null, // firstname null, // lastname null, // icq null, // homepage null, // zipcode null, // countrycode null, // birthday null, // sex null, // aim null, // pic null, // occ null, // ind null, // inc null, // mar null, // chc null, // i1 null, // nick null, // uniquenick null, // Bithmonth null, // Birthyear null // ProfileID }; if (recv.ContainsKey("publicmask")) { PublicMasks mask; if (Enum.TryParse(recv["publicmask"], out mask)) { if (client.PlayerInfo.PlayerPublicMask != mask) { query += ", publicmask=@P0"; client.PlayerInfo.PlayerPublicMask = mask; passData[0] = mask; } } } if (recv.ContainsKey("firstname")) { if (recv["firstname"] != client.PlayerInfo.PlayerFirstName) { query += ", firstname=@P1"; client.PlayerInfo.PlayerFirstName = recv["firstname"]; passData[1] = client.PlayerInfo.PlayerFirstName; } } if (recv.ContainsKey("lastname")) { if (recv["lastname"] != client.PlayerInfo.PlayerLastName) { query += ", lastname=@P2"; client.PlayerInfo.PlayerFirstName = recv["lastname"]; passData[2] = client.PlayerInfo.PlayerLastName; } } if (recv.ContainsKey("icquin")) { int icq = 0; if (int.TryParse(recv["icquin"], out icq)) { if (icq != client.PlayerInfo.PlayerICQ) { query += "icq=@P3 "; client.PlayerInfo.PlayerICQ = icq; passData[3] = icq; } } } if (recv.ContainsKey("homepage")) { if (recv["homepage"] != client.PlayerInfo.PlayerHomepage) { query += ", homepage=@P4"; client.PlayerInfo.PlayerHomepage = recv["homepage"]; passData[4] = client.PlayerInfo.PlayerHomepage; } } if (recv.ContainsKey("zipcode")) { if (recv["zipcode"] != client.PlayerInfo.PlayerZIPCode) { query += ", zipcode=@P5"; client.PlayerInfo.PlayerZIPCode = recv["zipcode"]; passData[5] = client.PlayerInfo.PlayerZIPCode; } } //if (recv.ContainsKey("countrycode")) //{ // if (recv["countrycode"] != client.PlayerInfo.PlayerCountryCode) // { // query += ", countrycode=@P6"; // client.PlayerInfo.PlayerCountryCode = recv["zipcode"]; // passData[6] = client.PlayerInfo.PlayerCountryCode; // } //} if (recv.ContainsKey("birthday")) { int date; if (int.TryParse(recv["birthday"], out date)) { ushort d = (ushort)((date >> 24) & 0xFF); ushort m = (ushort)((date >> 16) & 0xFF); ushort y = (ushort)(date & 0xFFFF); if (GameSpyUtils.IsValidDate(d, m, y)) { if (client.PlayerInfo.PlayerBirthday != d) { query += ", birthday=@P6"; passData[6] = d; client.PlayerInfo.PlayerBirthday = d; } if (client.PlayerInfo.PlayerBirthmonth != m) { query += ", birthmonth=@P19"; passData[19] = m; client.PlayerInfo.PlayerBirthmonth = m; } if (client.PlayerInfo.PlayerBirthyear != y) { query += ", birthyear=@P20"; passData[20] = y; client.PlayerInfo.PlayerBirthyear = y; } } } if (recv.ContainsKey("countrycode")) { if (recv["countrycode"] != client.PlayerInfo.PlayerCountryCode) { query += ", countrycode=@P7"; client.PlayerInfo.PlayerCountryCode = recv["zipcode"]; passData[7] = client.PlayerInfo.PlayerCountryCode; } } } if (recv.ContainsKey("sex")) { PlayerSexType sex; if (Enum.TryParse(recv["sex"], out sex)) { if (client.PlayerInfo.PlayerSex != sex) { query += "sex=@P8"; client.PlayerInfo.PlayerSex = sex; if (client.PlayerInfo.PlayerSex == PlayerSexType.MALE) { passData[8] = "MALE"; } else if (client.PlayerInfo.PlayerSex == PlayerSexType.FEMALE) { passData[8] = "FEMALE"; } else { passData[8] = "PAT"; } } } } if (recv.ContainsKey("aim")) { if (recv["aim"] != client.PlayerInfo.PlayerAim) { query += ", aim=@P9"; client.PlayerInfo.PlayerAim = recv["aim"]; passData[9] = client.PlayerInfo.PlayerAim; } } if (recv.ContainsKey("pic")) { int pic = 0; if (int.TryParse(recv["pic"], out pic)) { if (pic != client.PlayerInfo.PlayerPicture) { query += ", picture=@P10"; client.PlayerInfo.PlayerPicture = pic; passData[10] = pic; } } } if (recv.ContainsKey("occ")) { int occ = 0; if (int.TryParse(recv["occ"], out occ)) { if (occ != client.PlayerInfo.PlayerOccupation) { query += ", occupationid=@P11"; client.PlayerInfo.PlayerOccupation = occ; passData[11] = occ; } } } if (recv.ContainsKey("ind")) { int ind = 0; if (int.TryParse(recv["ind"], out ind)) { if (ind != client.PlayerInfo.PlayerIndustryID) { query += ", industryid=@P12"; client.PlayerInfo.PlayerIndustryID = ind; passData[12] = ind; } } } if (recv.ContainsKey("inc")) { int inc = 0; if (int.TryParse(recv["inc"], out inc)) { if (inc != client.PlayerInfo.PlayerIncomeID) { query += ", industryid=@P13"; client.PlayerInfo.PlayerIncomeID = inc; passData[13] = inc; } } } if (recv.ContainsKey("mar")) { int mar = 0; if (int.TryParse(recv["mar"], out mar)) { if (mar != client.PlayerInfo.PlayerMarried) { query += ", marriedid=@P14"; client.PlayerInfo.PlayerMarried = mar; passData[14] = mar; } } } if (recv.ContainsKey("chc")) { int chc = 0; if (int.TryParse(recv["chc"], out chc)) { if (chc != client.PlayerInfo.PlayerChildCount) { query += ", childcount=@P15"; client.PlayerInfo.PlayerChildCount = chc; passData[15] = chc; } } } if (recv.ContainsKey("i1")) { int i1 = 0; if (int.TryParse(recv["i1"], out i1)) { if (i1 != client.PlayerInfo.PlayerInterests) { query += ", interests1=@P16"; client.PlayerInfo.PlayerInterests = i1; passData[16] = i1; } } } if (recv.ContainsKey("nick")) { if (recv["nick"] != client.PlayerInfo.PlayerNick) { query += ", nick=@P17"; client.PlayerInfo.PlayerNick = recv["nick"]; passData[17] = client.PlayerInfo.PlayerNick; } } if (recv.ContainsKey("uniquenick")) { if (recv["uniquenick"] != client.PlayerInfo.PlayerUniqueNick) { query += ", uniquenick=@P18"; client.PlayerInfo.PlayerHomepage = recv["uniquenick"]; passData[18] = client.PlayerInfo.PlayerUniqueNick; } } if (query == "UPDATE profiles SET") { return; } query = query.Replace("SET,", "SET"); passData[21] = client.PlayerInfo.PlayerId; query += " WHERE `profileid`=@P21"; try { UpdateProQuery.UpdateUserInfo(query, passData); } catch (Exception e) { LogWriter.Log.WriteException(e); } }
private static string SetPlayerInfo(GPCMClient client, Dictionary <string, object> queryResult, Dictionary <string, string> recv) { client.PlayerInfo.PlayerId = uint.Parse(queryResult["profileid"].ToString()); client.PlayerInfo.PasswordHash = queryResult["password"].ToString().ToLowerInvariant(); client.PlayerInfo.PlayerCountryCode = queryResult["countrycode"].ToString(); client.PlayerInfo.PlayerFirstName = queryResult["firstname"].ToString(); client.PlayerInfo.PlayerLastName = queryResult["lastname"].ToString(); client.PlayerInfo.PlayerICQ = int.Parse(queryResult["icq"].ToString()); client.PlayerInfo.PlayerHomepage = queryResult["homepage"].ToString(); client.PlayerInfo.PlayerZIPCode = queryResult["zipcode"].ToString(); client.PlayerInfo.PlayerLocation = queryResult["location"].ToString(); client.PlayerInfo.PlayerAim = queryResult["aim"].ToString(); client.PlayerInfo.PlayerOwnership = int.Parse(queryResult["ownership1"].ToString()); client.PlayerInfo.PlayerOccupation = int.Parse(queryResult["occupationid"].ToString()); client.PlayerInfo.PlayerIndustryID = int.Parse(queryResult["industryid"].ToString()); client.PlayerInfo.PlayerIncomeID = int.Parse(queryResult["incomeid"].ToString()); client.PlayerInfo.PlayerMarried = int.Parse(queryResult["marriedid"].ToString()); client.PlayerInfo.PlayerChildCount = int.Parse(queryResult["childcount"].ToString()); client.PlayerInfo.PlayerConnectionType = int.Parse(queryResult["connectiontype"].ToString()); client.PlayerInfo.PlayerPicture = int.Parse(queryResult["picture"].ToString()); client.PlayerInfo.PlayerInterests = int.Parse(queryResult["interests1"].ToString()); client.PlayerInfo.PlayerBirthday = ushort.Parse(queryResult["birthday"].ToString()); client.PlayerInfo.PlayerBirthmonth = ushort.Parse(queryResult["birthmonth"].ToString()); client.PlayerInfo.PlayerBirthyear = ushort.Parse(queryResult["birthyear"].ToString()); PlayerSexType playerSexType; if (!Enum.TryParse(queryResult["sex"].ToString().ToUpper(), out playerSexType)) { client.PlayerInfo.PlayerSex = PlayerSexType.PAT; } else { client.PlayerInfo.PlayerSex = playerSexType; } client.PlayerInfo.PlayerLatitude = float.Parse(queryResult["latitude"].ToString()); client.PlayerInfo.PlayerLongitude = float.Parse(queryResult["longitude"].ToString()); PublicMasks mask; if (!Enum.TryParse(queryResult["publicmask"].ToString(), out mask)) { client.PlayerInfo.PlayerPublicMask = PublicMasks.MASK_ALL; } else { client.PlayerInfo.PlayerPublicMask = mask; } string challengeData; if (client.PlayerInfo.PlayerUniqueNick.Length > 0) { client.PlayerInfo.PlayerEmail = queryResult["email"].ToString(); client.PlayerInfo.PlayerNick = queryResult["nick"].ToString(); challengeData = client.PlayerInfo.PlayerUniqueNick; return(challengeData); } else if (client.PlayerInfo.PlayerAuthToken.Length > 0) { client.PlayerInfo.PlayerEmail = queryResult["email"].ToString(); client.PlayerInfo.PlayerNick = queryResult["nick"].ToString(); client.PlayerInfo.PlayerUniqueNick = queryResult["uniquenick"].ToString(); challengeData = client.PlayerInfo.PlayerAuthToken; return(challengeData); } else { client.PlayerInfo.PlayerUniqueNick = queryResult["uniquenick"].ToString(); challengeData = recv["user"]; return(challengeData); } }
/// <summary> /// This method verifies the login information sent by /// the client, and returns encrypted data for the client /// to verify as well /// </summary> public static void ProcessLogin(GPCMClient client, Dictionary <string, string> recv, GPCMConnectionUpdate OnSuccessfulLogin, GPCMStatusChanged OnStatusChanged) { uint partnerID = 0; // Make sure we have all the required data to process this login //if (!recv.ContainsKey("challenge") || !recv.ContainsKey("response")) //{ // GameSpyUtils.SendGPError(client, GPErrorCode.General, "Invalid response received from the client!"); // client.DisconnectByReason(DisconnectReason.InvalidLoginQuery); // return; //} if (IsContainAllKeys(recv) != GPErrorCode.NoError) { GameSpyUtils.SendGPError(client, GPErrorCode.General, "Invalid response received from the client!"); client.DisconnectByReason(DisconnectReason.InvalidLoginQuery); return; } // Parse the partnerid, required since it changes the challenge for Unique nick and User login ParseRequestToPlayerInfo(client, recv, ref partnerID); // Dispose connection after use try { // Try and fetch the user from the database Dictionary <string, object> queryResult; try { if (client.PlayerInfo.PlayerUniqueNick.Length > 0) { queryResult = LoginQuery.GetUserFromUniqueNick(recv); } else if (client.PlayerInfo.PlayerAuthToken.Length > 0) { //TODO! Add the database entry GameSpyUtils.SendGPError(client, GPErrorCode.General, "AuthToken is not supported yet"); return; } else { queryResult = LoginQuery.GetUserFromNickAndEmail(recv); } } catch (Exception ex) { LogWriter.Log.WriteException(ex); GameSpyUtils.SendGPError(client, GPErrorCode.DatabaseError, "This request cannot be processed because of a database error."); return; } //if no match found we disconnect the game if (queryResult == null) { if (client.PlayerInfo.PlayerUniqueNick.Length > 0) { GameSpyUtils.SendGPError(client, GPErrorCode.LoginBadUniquenick, "The uniquenick provided is incorrect!"); } else { GameSpyUtils.SendGPError(client, GPErrorCode.LoginBadUniquenick, "The information provided is incorrect!"); } client.DisconnectByReason(DisconnectReason.InvalidUsername); return; } // Check if user is banned string msg; DisconnectReason reason; GPErrorCode error = CheckUsersAccountAvailability(queryResult, out msg, out reason); if (error != GPErrorCode.NoError) { GameSpyUtils.SendGPError(client, error, msg); client.DisconnectByReason(reason); return; } // we finally set the player variables and return challengeData string challengeData = SetPlayerInfo(client, queryResult, recv); string sendingBuffer; // Use the GenerateProof method to compare with the "response" value. This validates the given password if (recv["response"] == GenerateProof(recv["challenge"], client.ServerChallengeKey, challengeData, client.PlayerInfo.PlayerAuthToken.Length > 0 ? 0 : partnerID, client.PlayerInfo)) { // Create session key client.SessionKey = Crc.ComputeChecksum(client.PlayerInfo.PlayerUniqueNick); //actually we should store sesskey in database at namespace table, when we want someone's profile we just //access to the sesskey to find the uniquenick for particular game LoginQuery.UpdateSessionKey(recv, client.SessionKey, client.PlayerInfo); // Password is correct sendingBuffer = string.Format(@"\lc\2\sesskey\{0}\proof\{1}\userid\{2}\profileid\{2}\uniquenick\{3}\lt\{4}__\id\1\final\", client.SessionKey, GenerateProof(client.ServerChallengeKey, recv["challenge"], challengeData, client.PlayerInfo.PlayerAuthToken.Length > 0 ? 0 : partnerID, client.PlayerInfo), // Do this again, Params are reversed! client.PlayerInfo.PlayerId, client.PlayerInfo.PlayerUniqueNick, // Generate LT whatever that is (some sort of random string, 22 chars long) GameSpyLib.Common.Random.GenerateRandomString(22, GameSpyLib.Common.Random.StringType.Hex) ); //Send response to client client.Send(sendingBuffer); // Log Incoming Connections //LogWriter.Log.Write(LogLevel.Info, "{0,-8} [Login] {1} - {2} - {3}", client.ServerName, client.PlayerInfo.PlayerNick, client.PlayerInfo.PlayerId, RemoteEndPoint); //string statusString = string.Format(" [Login Success!] Nick:{0} - Profileid:{1} - IP:{2}", client.PlayerInfo.PlayerNick, client.PlayerInfo.PlayerId, client.RemoteEndPoint); client.StatusToLog("Login Success", client.PlayerInfo.PlayerNick, client.PlayerInfo.PlayerId, client.RemoteEndPoint, null); // Update status last, and call success login client.PlayerInfo.LoginStatus = LoginStatus.Completed; client.PlayerInfo.PlayerStatus = PlayerStatus.Online; client.PlayerInfo.PlayerStatusString = "Online"; client.PlayerInfo.PlayerStatusLocation = ""; client.CompletedLoginProcess = true; OnSuccessfulLogin?.Invoke(client); OnStatusChanged?.Invoke(client); SendBuddiesHandler.HandleSendBuddies(client, recv); } else { // Log Incoming Connection string statusString = string.Format(@"[Login Failed!] Nick:{0} - Profileid:{1} - IP:{2}", client.PlayerInfo.PlayerNick, client.PlayerInfo.PlayerId, client.RemoteEndPoint); client.ToLog(LogLevel.Info, statusString); // Password is incorrect with database value. client.Send(@"\error\\err\260\fatal\\errmsg\The password provided is incorrect.\id\1\final\"); client.DisconnectByReason(DisconnectReason.InvalidPassword); } } catch (Exception ex) { LogWriter.Log.Write(ex.ToString(), LogLevel.Error); client.DisconnectByReason(DisconnectReason.GeneralError); return; } }
/// <summary> /// This method is called when the client requests for the Account profile /// </summary> public static void SendProfile(GPCMClient client, Dictionary <string, string> recv) { //TODO // \getprofile\\sesskey\19150\profileid\2\id\2\final\ //profileid is if (!recv.ContainsKey("profileid")) { GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "There was an error parsing an incoming request."); return; } uint targetPID, messID, sesskey; if (!uint.TryParse(recv["profileid"], out targetPID)) { GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "There was an error parsing an incoming request."); return; } if (!uint.TryParse(recv["id"], out messID)) { GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "There was an error parsing an incoming request."); return; } if (!uint.TryParse(recv["sesskey"], out sesskey)) { GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "There was an error parsing an incoming request."); return; } string datatoSend = @"\pi\profileid\" + targetPID + @"\mp\4"; // If the client want to access the public information // of another client if (targetPID != client.PlayerInfo.PlayerId) { GPCMPlayerInfo playerInfo = GetProfileQuery.GetProfileInfo(targetPID); if (playerInfo == null) { GameSpyUtils.SendGPError(client, 4, "Unable to get profile information."); return; } datatoSend = string.Format(datatoSend + @"\nick\{0}\uniquenick\{1}\id\{2}", playerInfo.PlayerNick, playerInfo.PlayerUniqueNick, messID); if (playerInfo.PlayerEmail.Length > 0) { datatoSend += @"\email\" + playerInfo.PlayerEmail; } if (playerInfo.PlayerLastName.Length > 0) { datatoSend += @"\lastname\" + playerInfo.PlayerLastName; } if (playerInfo.PlayerFirstName.Length > 0) { datatoSend += @"\firstname\" + playerInfo.PlayerFirstName; } if (playerInfo.PlayerICQ != 0) { datatoSend += @"\icquin\" + playerInfo.PlayerICQ; } if (playerInfo.PlayerHomepage.Length > 0) { datatoSend += @"\homepage\" + playerInfo.PlayerHomepage; } if (playerInfo.PlayerPicture != 0) { datatoSend += @"\pic\" + playerInfo.PlayerPicture; } if (playerInfo.PlayerAim.Length > 0) { datatoSend += @"\aim\" + playerInfo.PlayerAim; } if (playerInfo.PlayerOccupation != 0) { datatoSend += @"\occ\" + playerInfo.PlayerOccupation; } if (playerInfo.PlayerZIPCode.Length > 0) { datatoSend += @"\zipcode\" + playerInfo.PlayerZIPCode; } if (playerInfo.PlayerCountryCode.Length > 0) { datatoSend += @"\countrycode\" + playerInfo.PlayerCountryCode; } if (playerInfo.PlayerBirthday > 0 && playerInfo.PlayerBirthmonth > 0 && playerInfo.PlayerBirthyear > 0) { datatoSend += @"\birthday\" + (uint)((playerInfo.PlayerBirthday << 24) | (playerInfo.PlayerBirthmonth << 16) | playerInfo.PlayerBirthyear); } if (playerInfo.PlayerLocation.Length > 0) { datatoSend += @"\loc\" + playerInfo.PlayerLocation; } if (playerInfo.PlayerSex != PlayerSexType.PAT) { if (playerInfo.PlayerSex == PlayerSexType.FEMALE) { datatoSend += @"\sex\1"; } else if (playerInfo.PlayerSex == PlayerSexType.MALE) { datatoSend += @"\sex\0"; } } if (playerInfo.PlayerLatitude != 0.0f) { datatoSend += @"\lat\" + playerInfo.PlayerLatitude; } if (playerInfo.PlayerLongitude != 0.0f) { datatoSend += @"\lon\" + playerInfo.PlayerLongitude; } if (playerInfo.PlayerIncomeID != 0) { datatoSend += @"\inc\" + playerInfo.PlayerIncomeID; } if (playerInfo.PlayerIndustryID != 0) { datatoSend += @"\ind\" + playerInfo.PlayerIndustryID; } if (playerInfo.PlayerMarried != 0) { datatoSend += @"\mar\" + playerInfo.PlayerMarried; } if (playerInfo.PlayerChildCount != 0) { datatoSend += @"\chc\" + playerInfo.PlayerChildCount; } if (playerInfo.PlayerInterests != 0) { datatoSend += @"\i1\" + playerInfo.PlayerInterests; } if (playerInfo.PlayerOwnership != 0) { datatoSend += @"\o1\" + playerInfo.PlayerOwnership; } if (playerInfo.PlayerConnectionType != 0) { datatoSend += @"\conn\" + playerInfo.PlayerConnectionType; } // SUPER NOTE: Please check the Signature of the PID, otherwise when it will be compared with other peers, it will break everything (See gpiPeer.c @ peerSig) datatoSend += @"\sig\" + GameSpyLib.Common.Random.GenerateRandomString(33, GameSpyLib.Common.Random.StringType.Hex) + @"\final\"; } else { // Since this is our profile, we have to see ALL informations that we can edit. This means that we don't need to check the public masks for sending // the data datatoSend = string.Format(datatoSend + @"\nick\{0}\uniquenick\{1}\email\{2}\id\{3}\pmask\{4}", client.PlayerInfo.PlayerNick, client.PlayerInfo.PlayerUniqueNick, client.PlayerInfo.PlayerEmail, /*(ProfileSent ? "5" : "2")*/ messID, client.PlayerInfo.PlayerPublicMask ); if (client.PlayerInfo.PlayerLastName.Length > 0) { datatoSend += @"\lastname\" + client.PlayerInfo.PlayerLastName; } if (client.PlayerInfo.PlayerFirstName.Length > 0) { datatoSend += @"\firstname\" + client.PlayerInfo.PlayerFirstName; } if (client.PlayerInfo.PlayerICQ != 0) { datatoSend += @"\icquin\" + client.PlayerInfo.PlayerICQ; } if (client.PlayerInfo.PlayerHomepage.Length > 0) { datatoSend += @"\homepage\" + client.PlayerInfo.PlayerHomepage; } if (client.PlayerInfo.PlayerPicture != 0) { datatoSend += @"\pic\" + client.PlayerInfo.PlayerPicture; } if (client.PlayerInfo.PlayerAim.Length > 0) { datatoSend += @"\aim\" + client.PlayerInfo.PlayerAim; } if (client.PlayerInfo.PlayerOccupation != 0) { datatoSend += @"\occ\" + client.PlayerInfo.PlayerOccupation; } if (client.PlayerInfo.PlayerZIPCode.Length > 0) { datatoSend += @"\zipcode\" + client.PlayerInfo.PlayerZIPCode; } if (client.PlayerInfo.PlayerCountryCode.Length > 0) { datatoSend += @"\countrycode\" + client.PlayerInfo.PlayerCountryCode; } if (client.PlayerInfo.PlayerBirthday > 0 && client.PlayerInfo.PlayerBirthmonth > 0 && client.PlayerInfo.PlayerBirthyear > 0) { datatoSend += @"\birthday\" + (uint)((client.PlayerInfo.PlayerBirthday << 24) | (client.PlayerInfo.PlayerBirthmonth << 16) | client.PlayerInfo.PlayerBirthyear); } if (client.PlayerInfo.PlayerLocation.Length > 0) { datatoSend += @"\loc\" + client.PlayerInfo.PlayerLocation; } if (client.PlayerInfo.PlayerSex == PlayerSexType.FEMALE) { datatoSend += @"\sex\1"; } else if (client.PlayerInfo.PlayerSex == PlayerSexType.MALE) { datatoSend += @"\sex\0"; } if (client.PlayerInfo.PlayerLatitude != 0.0f) { datatoSend += @"\lat\" + client.PlayerInfo.PlayerLatitude; } if (client.PlayerInfo.PlayerLongitude != 0.0f) { datatoSend += @"\lon\" + client.PlayerInfo.PlayerLongitude; } if (client.PlayerInfo.PlayerIncomeID != 0) { datatoSend += @"\inc\" + client.PlayerInfo.PlayerIncomeID; } if (client.PlayerInfo.PlayerIndustryID != 0) { datatoSend += @"\ind\" + client.PlayerInfo.PlayerIndustryID; } if (client.PlayerInfo.PlayerMarried != 0) { datatoSend += @"\mar\" + client.PlayerInfo.PlayerMarried; } if (client.PlayerInfo.PlayerChildCount != 0) { datatoSend += @"\chc\" + client.PlayerInfo.PlayerChildCount; } if (client.PlayerInfo.PlayerInterests != 0) { datatoSend += @"\i1\" + client.PlayerInfo.PlayerInterests; } if (client.PlayerInfo.PlayerOwnership != 0) { datatoSend += @"\o1\" + client.PlayerInfo.PlayerOwnership; } if (client.PlayerInfo.PlayerConnectionType != 0) { datatoSend += @"\conn\" + client.PlayerInfo.PlayerConnectionType; } // SUPER NOTE: Please check the Signature of the PID, otherwise when it will be compared with other peers, it will break everything (See gpiPeer.c @ peerSig) datatoSend += @"\sig\" + GameSpyLib.Common.Random.GenerateRandomString(33, GameSpyLib.Common.Random.StringType.Hex) + @"\final\"; // Set that we send the profile initially if (!client.ProfileSent) { client.ProfileSent = true; } } client.Send(datatoSend); }