Index: src/login/account.h =================================================================== diff --git a/trunk/src/login/account.h b/trunk/src/login/account.h --- a/trunk/src/login/account.h (revision 17694) +++ b/trunk/src/login/account.h (working copy) @@ -25,6 +25,7 @@ char pass[32+1]; // 23+1 for plaintext, 32+1 for md5-ed passwords char sex; // gender (M/F/S) char email[40]; // e-mail (by default: a@a.com) + char mac_address[20]; // Mac Check [Ryuuzaki] int group_id; // player group id uint8 char_slots; // this accounts maximum character slots (maximum is limited to MAX_CHARS define in char server) unsigned int state; // packet 0x006a value + 1 (0: complete OK) Index: src/login/account_sql.c =================================================================== diff --git a/trunk/src/login/account_sql.c b/trunk/src/login/account_sql.c --- a/trunk/src/login/account_sql.c (revision 17694) +++ b/trunk/src/login/account_sql.c (working copy) @@ -566,7 +566,7 @@ sql_handle = db->accounts; // retrieve login entry for the specified account if( SQL_ERROR == SQL->Query(sql_handle, - "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", + "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", db->account_db, account_id ) ) { Sql_ShowDebug(sql_handle); @@ -595,6 +595,7 @@ SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data); SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode)); SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data); + SQL->GetData(sql_handle, 16, &data, NULL); safestrncpy(acc->mac_address, data, sizeof(acc->mac_address)); SQL->FreeResult(sql_handle); @@ -624,7 +625,7 @@ if( is_new ) {// insert into account table if( SQL_SUCCESS != SQL->StmtPrepare(stmt, - "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", db->account_db) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid)) @@ -642,6 +643,7 @@ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change)) + || SQL_SUCCESS != SQL->StmtBindParam(stmt, 16, SQLDT_STRING, (void*)acc->mac_address, strlen(acc->mac_address)) || SQL_SUCCESS != SQL->StmtExecute(stmt) ) { SqlStmt_ShowDebug(stmt); @@ -648,7 +650,7 @@ break; } } else {// update account table - 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) + 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) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex)) @@ -664,6 +666,7 @@ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change)) + || SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_STRING, (void*)acc->mac_address, strlen(acc->mac_address)) || SQL_SUCCESS != SQL->StmtExecute(stmt) ) { SqlStmt_ShowDebug(stmt); Index: src/login/login.c =================================================================== diff --git a/trunk/src/login/login.c b/trunk/src/login/login.c --- a/trunk/src/login/login.c (revision 17694) +++ b/trunk/src/login/login.c (working copy) @@ -1199,6 +1199,8 @@ sd->group_id = (uint8)acc.group_id; sd->expiration_time = acc.expiration_time; + memcpy(acc.mac_address, sd->mac_address, sizeof(acc.mac_address)); + // update account data timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), "%Y-%m-%d %H:%M:%S"); safestrncpy(acc.last_ip, ip, sizeof(acc.last_ip)); @@ -1462,8 +1464,12 @@ { char *accname = (char *)RFIFOP(fd, 9); char *token = (char *)RFIFOP(fd, 0x5C); + char *mac = {(char *)RFIFOP(fd, 60)}; size_t uAccLen = strlen(accname); + size_t uMac = 18; size_t uTokenLen = RFIFOREST(fd) - 0x5C; + safestrncpy(mac,mac, uMac); + safestrncpy(sd->mac_address,mac, uMac); version = RFIFOL(fd,4); Index: src/login/login.h =================================================================== diff --git a/trunk/src/login/login.h b/trunk/src/login/login.h --- a/trunk/src/login/login.h (revision 17694) +++ b/trunk/src/login/login.h (working copy) @@ -28,6 +28,8 @@ int login_id2; char sex;// 'F','M','S' + char mac_address[20]; + char userid[NAME_LENGTH]; char passwd[PASSWD_LEN]; int passwdenc;