summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt3
-rw-r--r--src/char/char.c164
-rw-r--r--src/char_sql/char.c30
3 files changed, 96 insertions, 101 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index bb9085301..f6b0eb8ac 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,7 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/03/27
- * Chagned trunk's default server->client PACKETVER to 9
+ * merged the charserver acc modification code cleanup to TXT (r11324)
+ * changed trunk's default server->client PACKETVER to 9
2008/03/26
* Adjusted eAthena code to compile cleanly in C++ mode.
2008/03/24
diff --git a/src/char/char.c b/src/char/char.c
index 566cd1e21..2a9c00943 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2926,108 +2926,96 @@ int parse_frommap(int fd)
RFIFOSKIP(fd, 86);
break;
- case 0x2b0e: // Request from map-server to change an account's status (all operations are transmitted to login-server)
+ case 0x2b0e: // Request from map-server to change an account's status (will just be forwarded to login server)
if (RFIFOREST(fd) < 44)
return 0;
{
+ int result = 0; // 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
char character_name[NAME_LENGTH];
- int acc = RFIFOL(fd,2); // account_id of who ask (-1 if nobody)
- memcpy(character_name, RFIFOP(fd,6), NAME_LENGTH);
- character_name[NAME_LENGTH-1] = '\0';
- // prepare answer
- WFIFOHEAD(fd,34);
- WFIFOW(fd,0) = 0x2b0f; // answer
- WFIFOL(fd,2) = acc; // who want do operation
- WFIFOW(fd,30) = RFIFOW(fd, 30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5-changesex
- // search character
+
+ int acc = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request)
+ const char* name = (char*)RFIFOP(fd,6); // name of the target character
+ int type = RFIFOW(fd,30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban
+ short year = RFIFOW(fd,32);
+ short month = RFIFOW(fd,34);
+ short day = RFIFOW(fd,36);
+ short hour = RFIFOW(fd,38);
+ short minute = RFIFOW(fd,40);
+ short second = RFIFOW(fd,42);
+ RFIFOSKIP(fd,44);
+
+ safestrncpy(character_name, name, NAME_LENGTH);
i = search_character_index(character_name);
- if (i >= 0) {
- memcpy(WFIFOP(fd,6), search_character_name(i), NAME_LENGTH); // put correct name if found
- WFIFOW(fd,6+NAME_LENGTH) = 0; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- //WFIFOW(fd,32) = 0; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- switch(RFIFOW(fd, 30)) {
+ if( i < 0 )
+ {
+ result = 1; // 1-player not found
+ }
+ else
+ {
+ char name[NAME_LENGTH];
+ int account_id;
+
+ account_id = char_dat[i].status.account_id;
+ safestrncpy(name, char_dat[i].status.name, NAME_LENGTH);
+
+ if( login_fd <= 0 )
+ result = 3; // 3-login-server offline
+ else
+ if( acc != -1 && isGM(acc) < isGM(account_id) )
+ result = 2; // 2-gm level too low
+ else
+ switch( type ) {
case 1: // block
- if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
- if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,10);
- WFIFOW(login_fd,0) = 0x2724;
- WFIFOL(login_fd,2) = char_dat[i].status.account_id; // account value
- WFIFOL(login_fd,6) = 5; // status of the account
- WFIFOSET(login_fd,10);
- } else
- WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- } else
- WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- break;
+ WFIFOHEAD(login_fd,10);
+ WFIFOW(login_fd,0) = 0x2724;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOL(login_fd,6) = 5; // new account status
+ WFIFOSET(login_fd,10);
+ break;
case 2: // ban
- if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
- if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,18);
- WFIFOW(login_fd, 0) = 0x2725;
- WFIFOL(login_fd, 2) = char_dat[i].status.account_id; // account value
- WFIFOW(login_fd, 6) = RFIFOW(fd,32); // year
- WFIFOW(login_fd, 8) = RFIFOW(fd,34); // month
- WFIFOW(login_fd,10) = RFIFOW(fd,36); // day
- WFIFOW(login_fd,12) = RFIFOW(fd,38); // hour
- WFIFOW(login_fd,14) = RFIFOW(fd,40); // minute
- WFIFOW(login_fd,16) = RFIFOW(fd,42); // second
- WFIFOSET(login_fd,18);
- } else
- WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- } else
- WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- break;
+ WFIFOHEAD(login_fd,18);
+ WFIFOW(login_fd, 0) = 0x2725;
+ WFIFOL(login_fd, 2) = account_id;
+ WFIFOW(login_fd, 6) = year;
+ WFIFOW(login_fd, 8) = month;
+ WFIFOW(login_fd,10) = day;
+ WFIFOW(login_fd,12) = hour;
+ WFIFOW(login_fd,14) = minute;
+ WFIFOW(login_fd,16) = second;
+ WFIFOSET(login_fd,18);
+ break;
case 3: // unblock
- if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
- if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,10);
- WFIFOW(login_fd,0) = 0x2724;
- WFIFOL(login_fd,2) = char_dat[i].status.account_id; // account value
- WFIFOL(login_fd,6) = 0; // status of the account
- WFIFOSET(login_fd,10);
- } else
- WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- } else
- WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- break;
+ WFIFOHEAD(login_fd,10);
+ WFIFOW(login_fd,0) = 0x2724;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOL(login_fd,6) = 0; // new account status
+ WFIFOSET(login_fd,10);
+ break;
case 4: // unban
- if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
- if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd, 0) = 0x272a;
- WFIFOL(login_fd, 2) = char_dat[i].status.account_id; // account value
- WFIFOSET(login_fd,6);
- } else
- WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- } else
- WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- break;
+ WFIFOHEAD(login_fd,6);
+ WFIFOW(login_fd,0) = 0x272a;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOSET(login_fd,6);
+ break;
case 5: // changesex
- if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
- if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd, 0) = 0x2727;
- WFIFOL(login_fd, 2) = char_dat[i].status.account_id; // account value
- WFIFOSET(login_fd,6);
- } else
- WFIFOW(fd,32) = 3; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- } else
- WFIFOW(fd,32) = 2; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- break;
+ WFIFOHEAD(login_fd,6);
+ WFIFOW(login_fd,0) = 0x2727;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOSET(login_fd,6);
+ break;
}
- } else {
- // character name not found
- memcpy(WFIFOP(fd,6), character_name, NAME_LENGTH);
- WFIFOW(fd,8+NAME_LENGTH) = 1; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
- //WFIFOW(fd,32) = 1; // answer: 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
}
+
// send answer if a player ask, not if the server ask
- if (acc != -1) {
- //WFIFOSET(fd, 34);
- WFIFOSET(fd, 10+NAME_LENGTH);
+ if( acc != -1 ) {
+ WFIFOHEAD(fd,34);
+ WFIFOW(fd, 0) = 0x2b0f;
+ WFIFOL(fd, 2) = acc;
+ safestrncpy((char*)WFIFOP(fd,6), name, NAME_LENGTH);
+ WFIFOW(fd,30) = type;
+ WFIFOW(fd,32) = result;
+ WFIFOSET(fd,34);
}
-
- RFIFOSKIP(fd, 44);
}
break;
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index ab243e217..f3a25f5fe 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -2521,13 +2521,20 @@ int parse_frommap(int fd)
if (RFIFOREST(fd) < 44)
return 0;
{
- int acc = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request)
- const char* name = (char*)RFIFOP(fd,6); // name of the target character
- int type = RFIFOW(fd, 30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban
-
int result = 0; // 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline
char esc_name[NAME_LENGTH*2+1];
+ int acc = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request)
+ const char* name = (char*)RFIFOP(fd,6); // name of the target character
+ int type = RFIFOW(fd,30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban
+ short year = RFIFOW(fd,32);
+ short month = RFIFOW(fd,34);
+ short day = RFIFOW(fd,36);
+ short hour = RFIFOW(fd,38);
+ short minute = RFIFOW(fd,40);
+ short second = RFIFOW(fd,42);
+ RFIFOSKIP(fd,44);
+
Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
Sql_ShowDebug(sql_handle);
@@ -2539,6 +2546,7 @@ int parse_frommap(int fd)
else
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
Sql_ShowDebug(sql_handle);
+ //FIXME: set proper result value?
else
{
char name[NAME_LENGTH];
@@ -2566,12 +2574,12 @@ int parse_frommap(int fd)
WFIFOHEAD(login_fd,18);
WFIFOW(login_fd, 0) = 0x2725;
WFIFOL(login_fd, 2) = account_id;
- WFIFOW(login_fd, 6) = RFIFOW(fd,32); // year
- WFIFOW(login_fd, 8) = RFIFOW(fd,34); // month
- WFIFOW(login_fd,10) = RFIFOW(fd,36); // day
- WFIFOW(login_fd,12) = RFIFOW(fd,38); // hour
- WFIFOW(login_fd,14) = RFIFOW(fd,40); // minute
- WFIFOW(login_fd,16) = RFIFOW(fd,42); // second
+ WFIFOW(login_fd, 6) = year;
+ WFIFOW(login_fd, 8) = month;
+ WFIFOW(login_fd,10) = day;
+ WFIFOW(login_fd,12) = hour;
+ WFIFOW(login_fd,14) = minute;
+ WFIFOW(login_fd,16) = second;
WFIFOSET(login_fd,18);
break;
case 3: // unblock
@@ -2608,8 +2616,6 @@ int parse_frommap(int fd)
WFIFOW(fd,32) = result;
WFIFOSET(fd,34);
}
-
- RFIFOSKIP(fd,44);
}
break;