Advertisement
Guest User

last mac patch

a guest
May 11th, 2015
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.71 KB | None | 0 0
  1. Index: src/login/account.h
  2. ===================================================================
  3. diff --git a/trunk/src/login/account.h b/trunk/src/login/account.h
  4. --- a/trunk/src/login/account.h (revision 17694)
  5. +++ b/trunk/src/login/account.h (working copy)
  6. @@ -25,6 +25,7 @@
  7.     char pass[32+1];            // 23+1 for plaintext, 32+1 for md5-ed passwords
  8.     char sex;                   // gender (M/F/S)
  9.     char email[40];             // e-mail (by default: a@a.com)
  10. +   char mac_address[20];       // Mac Check [Ryuuzaki]
  11.     int group_id;               // player group id
  12.     uint8 char_slots;           // this accounts maximum character slots (maximum is limited to MAX_CHARS define in char server)
  13.     unsigned int state;         // packet 0x006a value + 1 (0: complete OK)
  14. Index: src/login/account_sql.c
  15. ===================================================================
  16. diff --git a/trunk/src/login/account_sql.c b/trunk/src/login/account_sql.c
  17. --- a/trunk/src/login/account_sql.c (revision 17694)
  18. +++ b/trunk/src/login/account_sql.c (working copy)
  19. @@ -566,7 +566,7 @@
  20.     sql_handle = db->accounts;
  21.     // retrieve login entry for the specified account
  22.     if( SQL_ERROR == SQL->Query(sql_handle,
  23. -       "SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`group_id`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate`,`character_slots`,`pincode`,`pincode_change` FROM `%s` WHERE `account_id` = %d",
  24. +       "SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`group_id`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate`,`character_slots`,`pincode`,`pincode_change`,`last_mac` FROM `%s` WHERE `account_id` = %d",
  25.         db->account_db, account_id )
  26.     ) {
  27.         Sql_ShowDebug(sql_handle);
  28. @@ -595,6 +595,7 @@
  29.     SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data);
  30.     SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode));
  31.     SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data);
  32. +   SQL->GetData(sql_handle, 16, &data, NULL); safestrncpy(acc->mac_address, data, sizeof(acc->mac_address));
  33.  
  34.     SQL->FreeResult(sql_handle);
  35.  
  36. @@ -624,7 +625,7 @@
  37.     if( is_new )
  38.     {// insert into account table
  39.         if( SQL_SUCCESS != SQL->StmtPrepare(stmt,
  40. -           "INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`, `character_slots`, `pincode`, `pincode_change`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  41. +           "INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`, `character_slots`, `pincode`, `pincode_change`, `last_mac`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  42.             db->account_db)
  43.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt,  0, SQLDT_INT,    (void*)&acc->account_id,      sizeof(acc->account_id))
  44.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt,  1, SQLDT_STRING, (void*)acc->userid,           strlen(acc->userid))
  45. @@ -642,6 +643,7 @@
  46.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_UCHAR,  (void*)&acc->char_slots,      sizeof(acc->char_slots))
  47.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_STRING, (void*)&acc->pincode,         strlen(acc->pincode))
  48.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_LONG,   (void*)&acc->pincode_change,  sizeof(acc->pincode_change))
  49. +       ||  SQL_SUCCESS != SQL->StmtBindParam(stmt, 16, SQLDT_STRING, (void*)acc->mac_address,      strlen(acc->mac_address))
  50.         ||  SQL_SUCCESS != SQL->StmtExecute(stmt)
  51.         ) {
  52.             SqlStmt_ShowDebug(stmt);
  53. @@ -648,7 +650,7 @@
  54.             break;
  55.         }
  56.     } else {// update account table
  57. -       if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?,`pincode_change`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
  58. +       if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?,`pincode_change`=?, `last_mac`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
  59.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt,  0, SQLDT_STRING, (void*)acc->userid,           strlen(acc->userid))
  60.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt,  1, SQLDT_STRING, (void*)acc->pass,             strlen(acc->pass))
  61.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt,  2, SQLDT_ENUM,   (void*)&acc->sex,             sizeof(acc->sex))
  62. @@ -664,6 +666,7 @@
  63.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_UCHAR,  (void*)&acc->char_slots,      sizeof(acc->char_slots))
  64.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_STRING, (void*)&acc->pincode,         strlen(acc->pincode))
  65.         ||  SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_LONG,   (void*)&acc->pincode_change,  sizeof(acc->pincode_change))
  66. +       ||  SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_STRING, (void*)acc->mac_address,      strlen(acc->mac_address))
  67.         ||  SQL_SUCCESS != SQL->StmtExecute(stmt)
  68.         ) {
  69.             SqlStmt_ShowDebug(stmt);
  70. Index: src/login/login.c
  71. ===================================================================
  72. diff --git a/trunk/src/login/login.c b/trunk/src/login/login.c
  73. --- a/trunk/src/login/login.c   (revision 17694)
  74. +++ b/trunk/src/login/login.c   (working copy)
  75. @@ -1199,6 +1199,8 @@
  76.     sd->group_id = (uint8)acc.group_id;
  77.     sd->expiration_time = acc.expiration_time;
  78.  
  79. +   memcpy(acc.mac_address, sd->mac_address, sizeof(acc.mac_address));
  80. +
  81.     // update account data
  82.     timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), "%Y-%m-%d %H:%M:%S");
  83.     safestrncpy(acc.last_ip, ip, sizeof(acc.last_ip));
  84. @@ -1462,8 +1464,12 @@
  85.     {
  86.         char *accname = (char *)RFIFOP(fd, 9);
  87.         char *token = (char *)RFIFOP(fd, 0x5C);
  88. +       char *mac = {(char *)RFIFOP(fd, 60)};
  89.         size_t uAccLen = strlen(accname);
  90. +       size_t uMac = 18;
  91.         size_t uTokenLen = RFIFOREST(fd) - 0x5C;
  92. +       safestrncpy(mac,mac, uMac);
  93. +       safestrncpy(sd->mac_address,mac, uMac);
  94.  
  95.         version = RFIFOL(fd,4);
  96.  
  97. Index: src/login/login.h
  98. ===================================================================
  99. diff --git a/trunk/src/login/login.h b/trunk/src/login/login.h
  100. --- a/trunk/src/login/login.h   (revision 17694)
  101. +++ b/trunk/src/login/login.h   (working copy)
  102. @@ -28,6 +28,8 @@
  103.     int login_id2;
  104.     char sex;// 'F','M','S'
  105.  
  106. +   char mac_address[20];
  107. +
  108.     char userid[NAME_LENGTH];
  109.     char passwd[PASSWD_LEN];
  110.     int passwdenc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement