summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c878
-rw-r--r--src/char_sql/char.c769
-rw-r--r--src/char_sql/char.h2
-rw-r--r--src/char_sql/int_guild.c2
-rw-r--r--src/char_sql/int_homun.c11
-rw-r--r--src/char_sql/int_party.c10
-rw-r--r--src/char_sql/int_pet.c10
-rw-r--r--src/char_sql/int_storage.c10
-rw-r--r--src/common/core.h2
-rw-r--r--src/common/socket.h9
-rw-r--r--src/login/login.c529
-rw-r--r--src/login_sql/login.c330
-rw-r--r--src/login_sql/login.h6
-rw-r--r--src/map/chrif.c75
-rw-r--r--src/map/clif.c224
-rw-r--r--src/map/intif.c55
-rw-r--r--src/map/irc.c1
-rw-r--r--src/map/log.c6
-rw-r--r--src/map/mail.c12
-rw-r--r--src/map/map.c4
-rw-r--r--src/map/pc.c1
21 files changed, 1377 insertions, 1569 deletions
diff --git a/src/char/char.c b/src/char/char.c
index adfb40151..f1476bbb3 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -173,7 +173,8 @@ int console = 0;
//------------------------------
// Writing function of logs file
//------------------------------
-int char_log(char *fmt, ...) {
+int char_log(char *fmt, ...)
+{
if(log_char)
{
FILE *logfp;
@@ -204,7 +205,8 @@ int char_log(char *fmt, ...) {
// Determine if an account (id) is a GM account
// and returns its level (or 0 if it isn't a GM account or if not found)
//----------------------------------------------------------------------
-int isGM(int account_id) {
+int isGM(int account_id)
+{
int i;
for(i = 0; i < GM_num; i++)
@@ -214,7 +216,8 @@ int isGM(int account_id) {
}
//Search character data from the aid/cid givem
-struct mmo_charstatus* search_character(int aid, int cid) {
+struct mmo_charstatus* search_character(int aid, int cid)
+{
int i;
for (i = 0; i < char_num; i++) {
if (char_dat[i].status.char_id == cid && char_dat[i].status.account_id == aid)
@@ -238,7 +241,8 @@ struct mmo_charstatus* search_character_byname(char* character_name)
// and returns index if only 1 character is found
// and similar to the searched name.
//----------------------------------------------
-int search_character_index(char* character_name) {
+int search_character_index(char* character_name)
+{
int i, quantity, index;
quantity = 0;
@@ -265,8 +269,8 @@ int search_character_index(char* character_name) {
//-------------------------------------
// Return character name with the index
//-------------------------------------
-char * search_character_name(int index) {
-
+char * search_character_name(int index)
+{
if (index >= 0 && index < char_num)
return char_dat[index].status.name;
@@ -286,7 +290,8 @@ int search_character_online(int aid, int cid)
return server_fd[character->server];
return -1;
}
-static void * create_online_char_data(DBKey key, va_list args) {
+static void * create_online_char_data(DBKey key, va_list args)
+{
struct online_char_data* character;
character = aCalloc(1, sizeof(struct online_char_data));
character->account_id = key.i;
@@ -303,17 +308,21 @@ static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int dat
// Set Character online/offline [Wizputer]
//-------------------------------------------------
-void set_char_online(int map_id, int char_id, int account_id) {
+void set_char_online(int map_id, int char_id, int account_id)
+{
struct online_char_data* character;
-
- if ( char_id != 99 && (max_account_id < account_id || max_char_id < char_id))
- { //Notify map-server of the new max IDs [Skotlex]
- if (account_id > max_account_id)
- max_account_id = account_id;
- if (char_id > max_char_id)
- max_char_id = char_id;
- mapif_send_maxid(max_account_id, max_char_id);
+
+ if ( char_id != 99 ) {
+ if (max_account_id < account_id || max_char_id < char_id)
+ { //Notify map-server of the new max IDs [Skotlex]
+ if (account_id > max_account_id)
+ max_account_id = account_id;
+ if (char_id > max_char_id)
+ max_char_id = char_id;
+ mapif_send_maxid(max_account_id, max_char_id);
+ }
}
+
character = idb_ensure(online_char_db, account_id, create_online_char_data);
if (online_check && character->char_id != -1 && character->server > -1 && character->server != map_id)
{
@@ -325,23 +334,25 @@ void set_char_online(int map_id, int char_id, int account_id) {
character->account_id, character->char_id, character->server, map_id, account_id, char_id);
mapif_disconnectplayer(server_fd[character->server], character->account_id, character->char_id, 2);
}
- if(character->waiting_disconnect != -1){
- delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
- character->waiting_disconnect = -1;
- }
+
character->char_id = (char_id==99)?-1:char_id;
character->server = (char_id==99)?-1:map_id;
- if (login_fd <= 0 || session[login_fd]->eof)
- return;
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x272b;
- WFIFOL(login_fd,2) = account_id;
- WFIFOSET(login_fd,6);
-
- //printf ("set online\n");
+ if(character->waiting_disconnect != -1) {
+ delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
+ character->waiting_disconnect = -1;
+ }
+ if (login_fd > 0 && !session[login_fd]->eof)
+ {
+ WFIFOHEAD(login_fd,6);
+ WFIFOW(login_fd,0) = 0x272b;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOSET(login_fd,6);
+ }
}
-void set_char_offline(int char_id, int account_id) {
+
+void set_char_offline(int char_id, int account_id)
+{
struct online_char_data* character;
if ((character = idb_get(online_char_db, account_id)) != NULL)
@@ -353,16 +364,18 @@ void set_char_offline(int char_id, int account_id) {
character->waiting_disconnect = -1;
}
}
- if (login_fd <= 0 || session[login_fd]->eof)
- return;
- WFIFOHEAD(login_fd,6);
- WFIFOW(login_fd,0) = 0x272c;
- WFIFOL(login_fd,2) = account_id;
- WFIFOSET(login_fd,6);
+ if (login_fd > 0 && !session[login_fd]->eof)
+ {
+ WFIFOHEAD(login_fd,6);
+ WFIFOW(login_fd,0) = 0x272c;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOSET(login_fd,6);
+ }
}
-static int char_db_setoffline(DBKey key, void* data, va_list ap) {
+static int char_db_setoffline(DBKey key, void* data, va_list ap)
+{
struct online_char_data* character = (struct online_char_data*)data;
int server = va_arg(ap, int);
if (server == -1) {
@@ -377,7 +390,8 @@ static int char_db_setoffline(DBKey key, void* data, va_list ap) {
return 0;
}
-static int char_db_kickoffline(DBKey key, void* data, va_list ap) {
+static int char_db_kickoffline(DBKey key, void* data, va_list ap)
+{
struct online_char_data* character = (struct online_char_data*)data;
int server = va_arg(ap, int);
@@ -394,11 +408,12 @@ static int char_db_kickoffline(DBKey key, void* data, va_list ap) {
return 1;
}
-void set_all_offline(int id) {
+void set_all_offline(int id)
+{
if (id < 0)
ShowNotice("Sending all users offline.\n");
else
- ShowNotice("Sending users of map-server %d offline.\n", id);
+ ShowNotice("Sending users of map-server %d offline.\n",id);
online_char_db->foreach(online_char_db,char_db_kickoffline,id);
if (id >= 0 || login_fd <= 0 || session[login_fd]->eof)
@@ -431,7 +446,8 @@ int mmo_friends_list_data_str(char *str, struct mmo_charstatus *p)
//-------------------------------------------------
// Function to create the character line (for save)
//-------------------------------------------------
-int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int reg_num) {
+int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int reg_num)
+{
int i,j;
char *str_p = str;
@@ -501,7 +517,8 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg,
//-------------------------------------------------------------------------
// Function to set the character from the line (at read of characters file)
//-------------------------------------------------------------------------
-int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int *reg_num) {
+int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int *reg_num)
+{
char tmp_str[3][128]; //To avoid deleting chars with too long names.
int tmp_int[256];
unsigned int tmp_uint[2]; //To read exp....
@@ -875,7 +892,8 @@ int parse_friend_txt(struct mmo_charstatus *p)
//---------------------------------
// Function to read characters file
//---------------------------------
-int mmo_char_init(void) {
+int mmo_char_init(void)
+{
char line[65536];
int ret, line_count;
FILE *fp;
@@ -985,7 +1003,8 @@ int mmo_char_init(void) {
//---------------------------------------------------------
// Function to save characters in files (speed up by [Yor])
//---------------------------------------------------------
-void mmo_char_sync(void) {
+void mmo_char_sync(void)
+{
char line[65536],f_line[1024];
int i, j, k;
int lock;
@@ -1061,7 +1080,8 @@ void mmo_char_sync(void) {
//----------------------------------------------------
// Function to save (in a periodic way) datas in files
//----------------------------------------------------
-int mmo_char_sync_timer(int tid, unsigned int tick, int id, int data) {
+int mmo_char_sync_timer(int tid, unsigned int tick, int id, int data)
+{
if (save_log)
ShowInfo("Saving all files...\n");
mmo_char_sync();
@@ -1072,7 +1092,8 @@ int mmo_char_sync_timer(int tid, unsigned int tick, int id, int data) {
//-----------------------------------
// Function to create a new character
//-----------------------------------
-int make_new_char(int fd, unsigned char *dat) {
+int make_new_char(int fd, unsigned char *dat)
+{
int i;
struct char_session_data *sd;
char name[NAME_LENGTH];
@@ -1237,7 +1258,8 @@ int make_new_char(int fd, unsigned char *dat) {
//----------------------------------------------------
// This function return the name of the job (by [Yor])
//----------------------------------------------------
-char * job_name(int class_) {
+char * job_name(int class_)
+{
switch (class_) {
case JOB_NOVICE: return "Novice";
case JOB_SWORDMAN: return "Swordsman";
@@ -1429,7 +1451,8 @@ static int create_online_files_sub(DBKey key, void* data, va_list va)
//-------------------------------------------------------------
// Function to create the online files (txt and html). by [Yor]
//-------------------------------------------------------------
-void create_online_files(void) {
+void create_online_files(void)
+{
unsigned int k, j; // for loop with strlen comparing
int i, l; // for loops
int players; // count the number of players
@@ -1623,7 +1646,8 @@ void create_online_files(void) {
//---------------------------------------------------------------------
// This function return the number of online players in all map-servers
//---------------------------------------------------------------------
-int count_users(void) {
+int count_users(void)
+{
int i, users;
users = 0;
@@ -1696,7 +1720,8 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
//----------------------------------------
// Function to send characters to a player
//----------------------------------------
-int mmo_char_send006b(int fd, struct char_session_data *sd) {
+int mmo_char_send006b(int fd, struct char_session_data *sd)
+{
int i, j, found_num;
set_char_online(-1, 99, sd->account_id);
@@ -1729,7 +1754,8 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) {
}
// 離婚(char削除時に使用)
-int char_divorce(struct mmo_charstatus *cs) {
+int char_divorce(struct mmo_charstatus *cs)
+{
if (cs == NULL)
return 0;
@@ -1751,17 +1777,20 @@ int char_divorce(struct mmo_charstatus *cs) {
return 0;
}
-int char_married(int pl1,int pl2) {
+int char_married(int pl1,int pl2)
+{
return (char_dat[pl1].status.char_id == char_dat[pl2].status.partner_id && char_dat[pl2].status.char_id == char_dat[pl1].status.partner_id);
}
-int char_child(int parent_id, int child_id) {
+int char_child(int parent_id, int child_id)
+{
return (char_dat[parent_id].status.child == char_dat[child_id].status.char_id &&
((char_dat[parent_id].status.char_id == char_dat[child_id].status.father) ||
(char_dat[parent_id].status.char_id == char_dat[child_id].status.mother)));
}
-int char_family(int cid1, int cid2, int cid3) {
+int char_family(int cid1, int cid2, int cid3)
+{
int i, idx1 = -1, idx2 =-1;//, idx3 =-1;
for(i = 0; i < char_num && (idx1 == -1 || idx2 == -1/* || idx3 == 1*/); i++)
{
@@ -1807,7 +1836,8 @@ void char_clearparty(int party_id)
//----------------------------------------------------------------------
// Force disconnection of an online player (with account value) by [Yor]
//----------------------------------------------------------------------
-int disconnect_player(int account_id) {
+int disconnect_player(int account_id)
+{
int i;
struct char_session_data *sd;
@@ -1825,7 +1855,8 @@ int disconnect_player(int account_id) {
}
// キャラ削除に伴うデータ削除
-static int char_delete(struct mmo_charstatus *cs) {
+static int char_delete(struct mmo_charstatus *cs)
+{
int j;
// ペット削除
@@ -1909,10 +1940,10 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
int send_accounts_tologin(int tid, unsigned int tick, int id, int data);
-int parse_tologin(int fd) {
+int parse_tologin(int fd)
+{
int i;
struct char_session_data *sd;
- RFIFOHEAD(fd);
// only login-server can have an access to here.
// so, if it isn't the login-server, we disconnect the session (fd != login_fd).
@@ -1937,36 +1968,38 @@ int parse_tologin(int fd) {
if (RFIFOREST(fd) < 3)
return 0;
if (RFIFOB(fd,2)) {
-// printf("connect login server error : %d\n", RFIFOB(fd,2));
+ //printf("connect login server error : %d\n", RFIFOB(fd,2));
ShowError("Can not connect to the login-server.\n");
ShowError("The server communication passwords (default s1/p1) are probably invalid.\n");
ShowInfo("Also, please make sure your accounts file (default: accounts.txt) has those values present.\n");
ShowInfo("The communication passwords can be changed in map_athena.conf and char_athena.conf\n");
- exit(1);
+ //exit(1); //fixed for server shutdown.
} else {
ShowStatus("Connected to login-server (connection #%d).\n", fd);
- //Send to login accounts currently connected.
+ //Send online accounts to login server.
send_accounts_tologin(-1, gettick(), 0, 0);
// if no map-server already connected, display a message...
for(i = 0; i < MAX_MAP_SERVERS; i++)
- if (server_fd[i] >= 0 && server[i].map[0]) // if map-server online and at least 1 map
+ if (server_fd[i] > 0 && server[i].map[0]) // if map-server online and at least 1 map
break;
if (i == MAX_MAP_SERVERS)
ShowStatus("Awaiting maps from map-server.\n");
}
RFIFOSKIP(fd,3);
- break;
+ break;
case 0x2713:
if (RFIFOREST(fd) < 51)
return 0;
+
for(i = 0; i < fd_max && !(
session[i] &&
(sd = (struct char_session_data*)session[i]->session_data) &&
sd->account_id == RFIFOL(fd,2))
; i++);
+
if (i < fd_max) {
if (RFIFOB(fd,6) != 0) {
WFIFOHEAD(i,3);
@@ -1982,7 +2015,7 @@ int parse_tologin(int fd) {
}
}
RFIFOSKIP(fd,51);
- break;
+ break;
// Receiving of an e-mail/time limit from the login-server (answer of a request because a player comes back from map-server to char-server) by [Yor]
case 0x2717:
@@ -2000,14 +2033,14 @@ int parse_tologin(int fd) {
}
}
RFIFOSKIP(fd,50);
- break;
+ break;
// login-server alive packet
case 0x2718:
if (RFIFOREST(fd) < 2)
return 0;
RFIFOSKIP(fd,2);
- break;
+ break;
// Receiving authentification from Freya-type login server (to avoid char->login->char)
case 0x2719:
@@ -2033,31 +2066,31 @@ int parse_tologin(int fd) {
auth_fifo[i].connect_until_time = 0; // unlimited/unknown time by default (not display in map-server)
auth_fifo[i].ip = ntohl(RFIFOL(fd,14));
RFIFOSKIP(fd,18);
- break;
+ break;
case 0x2721: // gm reply
if (RFIFOREST(fd) < 10)
return 0;
- {
+ {
unsigned char buf[10];
WBUFW(buf,0) = 0x2b0b;
WBUFL(buf,2) = RFIFOL(fd,2); // account
WBUFL(buf,6) = RFIFOL(fd,6); // GM level
mapif_sendall(buf,10);
// printf("parse_tologin: To become GM answer: char -> map.\n");
- }
+
RFIFOSKIP(fd,10);
- break;
+ }
+ break;
case 0x2723: // changesex reply (modified by [Yor])
if (RFIFOREST(fd) < 7)
return 0;
- {
+ {
int acc, sex, i, j;
unsigned char buf[7];
acc = RFIFOL(fd,2);
sex = RFIFOB(fd,6);
- RFIFOSKIP(fd, 7);
if (acc > 0) {
for(i = 0; i < AUTH_FIFO_SIZE; i++) {
if (auth_fifo[i].account_id == acc)
@@ -2124,15 +2157,18 @@ int parse_tologin(int fd) {
WBUFL(buf,2) = acc;
WBUFB(buf,6) = sex;
mapif_sendall(buf, 7);
- }
- break;
+
+ RFIFOSKIP(fd,7);
+ }
+ break;
case 0x2726: // Request to send a broadcast message (no answer)
if (RFIFOREST(fd) < 8 || RFIFOREST(fd) < (8 + RFIFOL(fd,4)))
return 0;
if (RFIFOL(fd,4) < 1)
char_log("Receiving a message for broadcast, but message is void." RETCODE);
- else {
+ else
+ {
// at least 1 map-server
for(i = 0; i < MAX_MAP_SERVERS; i++)
if (server_fd[i] >= 0)
@@ -2192,21 +2228,21 @@ int parse_tologin(int fd) {
}
}
RFIFOSKIP(fd,8 + RFIFOL(fd,4));
- break;
+ break;
// account_reg2変更通知
case 0x2729:
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
- { //Receive account_reg2 registry, forward to map servers.
+ { //Receive account_reg2 registry, forward to map servers.
unsigned char buf[ACCOUNT_REG2_NUM*(256+32+2)+16];
memcpy(buf,RFIFOP(fd,0), RFIFOW(fd,2));
// WBUFW(buf,0) = 0x2b11;
WBUFW(buf,0) = 0x3804; //Map server can now receive all kinds of reg values with the same packet. [Skotlex]
mapif_sendall(buf, WBUFW(buf,2));
RFIFOSKIP(fd, RFIFOW(fd,2));
- }
- break;
+ }
+ break;
// Account deletion notification (from login-server)
case 0x2730:
@@ -2254,31 +2290,31 @@ int parse_tologin(int fd) {
// disconnect player if online on char-server
disconnect_player(RFIFOL(fd,2));
RFIFOSKIP(fd,6);
- break;
+ break;
// State change of account/ban notification (from login-server) by [Yor]
case 0x2731:
if (RFIFOREST(fd) < 11)
return 0;
// send to all map-servers to disconnect the player
- {
- unsigned char buf[11];
- WBUFW(buf,0) = 0x2b14;
- WBUFL(buf,2) = RFIFOL(fd,2);
- WBUFB(buf,6) = RFIFOB(fd,6); // 0: change of statut, 1: ban
- WBUFL(buf,7) = RFIFOL(fd,7); // status or final date of a banishment
- mapif_sendall(buf, 11);
- }
+ {
+ unsigned char buf[11];
+ WBUFW(buf,0) = 0x2b14;
+ WBUFL(buf,2) = RFIFOL(fd,2);
+ WBUFB(buf,6) = RFIFOB(fd,6); // 0: change of statut, 1: ban
+ WBUFL(buf,7) = RFIFOL(fd,7); // status or final date of a banishment
+ mapif_sendall(buf, 11);
+ }
// disconnect player if online on char-server
disconnect_player(RFIFOL(fd,2));
RFIFOSKIP(fd,11);
- break;
+ break;
// Receiving GM acounts info from login-server (by [Yor])
case 0x2732:
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
- {
+ {
unsigned char buf[32000];
if (gm_account != NULL)
aFree(gm_account);
@@ -2297,107 +2333,107 @@ int parse_tologin(int fd) {
memcpy(buf, RFIFOP(fd,0), RFIFOW(fd,2));
WBUFW(buf,0) = 0x2b15;
mapif_sendall(buf, RFIFOW(fd,2));
- }
+
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+ }
+ break;
// Receive GM accounts [Freya login server packet by Yor]
case 0x2733:
- // add test here to remember that the login-server is Freya-type
- // sprintf (login_server_type, "Freya");
if (RFIFOREST(fd) < 7)
return 0;
- {
- unsigned char buf[32000];
- int new_level = 0;
- for(i = 0; i < GM_num; i++)
- if (gm_account[i].account_id == RFIFOL(fd,2)) {
- if (gm_account[i].level != (int)RFIFOB(fd,6)) {
- gm_account[i].level = (int)RFIFOB(fd,6);
- new_level = 1;
- }
- break;
- }
- // if not found, add it
- if (i == GM_num) {
- // limited to 4000, because we send information to char-servers (more than 4000 GM accounts???)
- // int (id) + int (level) = 8 bytes * 4000 = 32k (limit of packets in windows)
- if (((int)RFIFOB(fd,6)) > 0 && GM_num < 4000) {
- if (GM_num == 0) {
- gm_account = (struct gm_account*)aMalloc(sizeof(struct gm_account));
- } else {
- gm_account = (struct gm_account*)aRealloc(gm_account, sizeof(struct gm_account) * (GM_num + 1));
- }
- gm_account[GM_num].account_id = RFIFOL(fd,2);
- gm_account[GM_num].level = (int)RFIFOB(fd,6);
+ {
+ int new_level = 0;
+ for(i = 0; i < GM_num; i++)
+ if (gm_account[i].account_id == RFIFOL(fd,2)) {
+ if (gm_account[i].level != (int)RFIFOB(fd,6)) {
+ gm_account[i].level = (int)RFIFOB(fd,6);
new_level = 1;
- GM_num++;
- if (GM_num >= 4000) {
- ShowWarning("4000 GM accounts found. Next GM accounts are not readed.\n");
- char_log("***WARNING: 4000 GM accounts found. Next GM accounts are not readed." RETCODE);
- }
}
+ break;
}
- if (new_level == 1) {
- int len;
- ShowStatus("From login-server: receiving GM account information (%d: level %d).\n", RFIFOL(fd,2), (int)RFIFOB(fd,6));
- char_log("From login-server: receiving a GM account information (%d: level %d)." RETCODE, RFIFOL(fd,2), (int)RFIFOB(fd,6));
- //create_online_files(); // not change online file for only 1 player (in next timer, that will be done
- // send gm acccounts level to map-servers
- len = 4;
- WBUFW(buf,0) = 0x2b15;
-
- for(i = 0; i < GM_num; i++) {
- WBUFL(buf, len) = gm_account[i].account_id;
- WBUFB(buf, len+4) = (unsigned char)gm_account[i].level;
- len += 5;
+ // if not found, add it
+ if (i == GM_num) {
+ // limited to 4000, because we send information to char-servers (more than 4000 GM accounts???)
+ // int (id) + int (level) = 8 bytes * 4000 = 32k (limit of packets in windows)
+ if (((int)RFIFOB(fd,6)) > 0 && GM_num < 4000) {
+ if (GM_num == 0) {
+ gm_account = (struct gm_account*)aMalloc(sizeof(struct gm_account));
+ } else {
+ gm_account = (struct gm_account*)aRealloc(gm_account, sizeof(struct gm_account) * (GM_num + 1));
+ }
+ gm_account[GM_num].account_id = RFIFOL(fd,2);
+ gm_account[GM_num].level = (int)RFIFOB(fd,6);
+ new_level = 1;
+ GM_num++;
+ if (GM_num >= 4000) {
+ ShowWarning("4000 GM accounts found. Next GM accounts are not readed.\n");
+ char_log("***WARNING: 4000 GM accounts found. Next GM accounts are not readed." RETCODE);
}
- WBUFW(buf, 2) = len;
- mapif_sendall(buf, len);
}
}
+ if (new_level == 1) {
+ unsigned char buf[32000];
+ int len;
+ ShowStatus("From login-server: receiving GM account information (%d: level %d).\n", RFIFOL(fd,2), (int)RFIFOB(fd,6));
+ char_log("From login-server: receiving a GM account information (%d: level %d)." RETCODE, RFIFOL(fd,2), (int)RFIFOB(fd,6));
+ //create_online_files(); // not change online file for only 1 player (in next timer, that will be done
+ // send gm acccounts level to map-servers
+ len = 4;
+ WBUFW(buf,0) = 0x2b15;
+
+ for(i = 0; i < GM_num; i++) {
+ WBUFL(buf, len) = gm_account[i].account_id;
+ WBUFB(buf, len+4) = (unsigned char)gm_account[i].level;
+ len += 5;
+ }
+ WBUFW(buf, 2) = len;
+ mapif_sendall(buf, len);
+ }
+
RFIFOSKIP(fd,7);
- break;
+ }
+ break;
//Login server request to kick a character out. [Skotlex]
case 0x2734:
if (RFIFOREST(fd) < 6)
return 0;
- {
- struct online_char_data* character;
- int aid = RFIFOL(fd,2);
- if ((character = idb_get(online_char_db, aid)) != NULL)
- { //Kick out this player.
- if (character->server > -1)
- { //Kick it from the map server it is on.
- mapif_disconnectplayer(server_fd[character->server], character->account_id, character->char_id, 2);
- if (character->waiting_disconnect == -1)
- character->waiting_disconnect = add_timer(gettick()+15000, chardb_waiting_disconnect, character->account_id, 0);
- } else { //Manual kick from char server.
- struct char_session_data *tsd;
- int i;
- for(i = 0; i < fd_max; i++) {
- if (session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid)
- {
- WFIFOHEAD(i,3);
- WFIFOW(i,0) = 0x81;
- WFIFOB(i,2) = 2;
- WFIFOSET(i,3);
- break;
- }
+ {
+ struct online_char_data* character;
+ int aid = RFIFOL(fd,2);
+ if ((character = idb_get(online_char_db, aid)) != NULL)
+ { //Kick out this player.
+ if (character->server > -1)
+ { //Kick it from the map server it is on.
+ mapif_disconnectplayer(server_fd[character->server], character->account_id, character->char_id, 2);
+ if (character->waiting_disconnect == -1)
+ character->waiting_disconnect = add_timer(gettick()+15000, chardb_waiting_disconnect, character->account_id, 0);
+ } else { //Manual kick from char server.
+ struct char_session_data *tsd;
+ int i;
+ for(i = 0; i < fd_max; i++) {
+ if (session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid)
+ {
+ WFIFOHEAD(i,3);
+ WFIFOW(i,0) = 0x81;
+ WFIFOB(i,2) = 2;
+ WFIFOSET(i,3);
+ break;
}
- if (i == fd_max) //Shouldn't happen, but just in case.
- set_char_offline(99, aid);
}
+ if (i == fd_max) //Shouldn't happen, but just in case.
+ set_char_offline(99, aid);
}
- RFIFOSKIP(fd,6);
}
- break;
+ RFIFOSKIP(fd,6);
+ }
+ break;
+
case 0x2735:
{
unsigned char buf[2];
uint32 new_ip = 0;
- RFIFOSKIP(fd,2);
WBUFW(buf,0) = 0x2b1e;
mapif_sendall(buf, 2);
@@ -2409,27 +2445,31 @@ int parse_tologin(int fd) {
new_ip = host2ip(char_ip_str);
if (new_ip && new_ip != char_ip)
{ //Update ip.
- WFIFOHEAD(fd,6);
char_ip = new_ip;
ShowInfo("Updating IP for [%s].\n", char_ip_str);
+ WFIFOHEAD(fd,6);
WFIFOW(fd,0) = 0x2736;
WFIFOL(fd,2) = htonl(char_ip);
WFIFOSET(fd,6);
}
- break;
+
+ RFIFOSKIP(fd,2);
}
+ break;
+
default:
- ShowWarning("Unknown packet 0x%04x received from login-server, disconnecting.\n", RFIFOW(fd,0));
+ ShowError("Unknown packet 0x%04x received from login-server, disconnecting.\n", RFIFOW(fd,0));
set_eof(fd);
return 0;
}
}
- RFIFOFLUSH(fd);
+ RFIFOFLUSH(fd);
return 0;
}
-int request_accreg2(int account_id, int char_id) {
+int request_accreg2(int account_id, int char_id)
+{
if (login_fd > 0) {
WFIFOHEAD(login_fd,10);
WFIFOW(login_fd,0) = 0x272e;
@@ -2442,7 +2482,8 @@ int request_accreg2(int account_id, int char_id) {
}
//Send packet forward to login-server for account saving
-int save_accreg2(unsigned char* buf, int len) {
+int save_accreg2(unsigned char* buf, int len)
+{
if (login_fd > 0) {
WFIFOHEAD(login_fd,len+4);
memcpy(WFIFOP(login_fd,4), buf, len);
@@ -2455,7 +2496,8 @@ int save_accreg2(unsigned char* buf, int len) {
}
//Receive Registry information for a character.
-int char_parse_Registry(int account_id, int char_id, unsigned char *buf, int buf_len) {
+int char_parse_Registry(int account_id, int char_id, unsigned char *buf, int buf_len)
+{
int i,j,p,len;
for (i = 0; i < char_num; i++) {
if (char_dat[i].status.account_id == account_id && char_dat[i].status.char_id == char_id)
@@ -2476,7 +2518,8 @@ int char_parse_Registry(int account_id, int char_id, unsigned char *buf, int buf
}
//Reply to map server with acc reg values.
-int char_account_reg_reply(int fd,int account_id,int char_id) {
+int char_account_reg_reply(int fd,int account_id,int char_id)
+{
int i,j,p;
WFIFOHEAD(fd, GLOBAL_REG_NUM*288 + 13);
WFIFOW(fd,0)=0x3804;
@@ -2572,7 +2615,8 @@ void char_read_fame_list(void)
DELETE_BUFFER(id);
}
// Send map-servers the fame ranking lists
-int char_send_fame_list(int fd) {
+int char_send_fame_list(int fd)
+{
int i, len = 8;
unsigned char buf[32000];
@@ -2623,17 +2667,16 @@ int parse_frommap(int fd)
{
int i, j;
int id;
- RFIFOHEAD(fd);
for(id = 0; id < MAX_MAP_SERVERS; id++)
if (server_fd[id] == fd)
break;
- if(id==MAX_MAP_SERVERS)
+ if(id == MAX_MAP_SERVERS)
set_eof(fd);
- if(session[fd]->eof){
+ if(session[fd]->eof) {
if (id < MAX_MAP_SERVERS) {
unsigned char buf[16384];
- ShowStatus("Map-server %d has disconnected.\n", id);
+ ShowStatus("Map-server %d (session #%d) has disconnected.\n", id, fd);
//Notify other map servers that this one is gone. [Skotlex]
WBUFW(buf,0) = 0x2b20;
WBUFL(buf,4) = htonl(server[id].ip);
@@ -2654,16 +2697,16 @@ int parse_frommap(int fd)
return 0;
}
- while(RFIFOREST(fd) >= 2) {
+ while(RFIFOREST(fd) >= 2)
+ {
//ShowDebug("Received packet 0x%4x (%d bytes) from map-server (connection %d)\n", RFIFOW(fd, 0), RFIFOREST(fd), fd);
- switch(RFIFOW(fd,0)) {
+ switch(RFIFOW(fd,0))
+ {
case 0x2718: // map-server alive packet
- if (RFIFOREST(fd) < 2)
- return 0;
RFIFOSKIP(fd,2);
- break;
+ break;
case 0x2af7: // request from map-server to reload GM accounts. Transmission to login-server
if (login_fd > 0) { // don't send request if no login-server
@@ -2672,7 +2715,7 @@ int parse_frommap(int fd)
WFIFOSET(login_fd,2);
}
RFIFOSKIP(fd,2);
- break;
+ break;
case 0x2afa: // Receiving map names list from the map-server
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -2681,7 +2724,7 @@ int parse_frommap(int fd)
memset(server[id].map, 0, sizeof(server[id].map));
j = 0;
for(i = 4; i < RFIFOW(fd,2); i += 4) {
- server[id].map[j] = RFIFOW(fd,i);
+ server[id].map[j] = RFIFOW(fd,i);
j++;
}
@@ -2719,7 +2762,8 @@ int parse_frommap(int fd)
}
// Transmitting the maps of the other map-servers to the new map-server
for(x = 0; x < MAX_MAP_SERVERS; x++) {
- if (server_fd[x] >= 0 && x != id) {
+ if (server_fd[x] > 0 && x != id) {
+ WFIFOHEAD(fd,10 +4*MAX_MAP_PER_SERVER);
WFIFOW(fd,0) = 0x2b04;
WFIFOL(fd,4) = htonl(server[x].ip);
WFIFOW(fd,8) = htons(server[x].port);
@@ -2735,7 +2779,7 @@ int parse_frommap(int fd)
}
}
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+ break;
case 0x2afc: //Packet command is now used for sc_data request. [Skotlex]
if (RFIFOREST(fd) < 10)
@@ -2746,9 +2790,6 @@ int parse_frommap(int fd)
struct scdata *data;
aid = RFIFOL(fd,2);
cid = RFIFOL(fd,6);
-#endif
- RFIFOSKIP(fd, 10);
-#ifdef ENABLE_SC_SAVING
data = status_search_scdata(aid, cid);
if (data->count > 0)
{ //Deliver status change data.
@@ -2763,8 +2804,9 @@ int parse_frommap(int fd)
status_delete_scdata(aid, cid); //Data sent, so it needs be discarded now.
}
#endif
- break;
+ RFIFOSKIP(fd, 10);
}
+ break;
case 0x2afe: //set MAP user count
if (RFIFOREST(fd) < 4)
@@ -2806,7 +2848,7 @@ int parse_frommap(int fd)
}
//If any chars remain in -2, they will be cleaned in the cleanup timer.
RFIFOSKIP(fd,6+i*8);
- break;
+ break;
case 0x2b01: // Receive character data from map-server for saving
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -2827,7 +2869,7 @@ int parse_frommap(int fd)
WFIFOSET(fd,10);
}
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+ break;
case 0x2b02: // req char selection
if (RFIFOREST(fd) < 18)
@@ -2844,67 +2886,70 @@ int parse_frommap(int fd)
auth_fifo[auth_fifo_pos].connect_until_time = 0; // unlimited/unknown time by default (not display in map-server)
auth_fifo[auth_fifo_pos].ip = ntohl(RFIFOL(fd,14));
auth_fifo_pos++;
+ WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x2b03;
WFIFOL(fd,2) = RFIFOL(fd,2);
WFIFOB(fd,6) = 0;
WFIFOSET(fd,7);
RFIFOSKIP(fd,18);
- break;
+ break;
case 0x2b05: // request "change map server"
if (RFIFOREST(fd) < 35)
return 0;
- {
- unsigned short name;
- int map_id, map_fd = -1;
- struct online_char_data* data;
- struct mmo_charstatus* char_data;
-
- name = RFIFOW(fd,18);
- map_id = search_mapserver(name, ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
- if (map_id >= 0)
- map_fd = server_fd[map_id];
- for(i = 0; i < char_num; i++) {
- if (char_dat[i].status.account_id == RFIFOL(fd,2) &&
- char_dat[i].status.char_id == RFIFOL(fd,14))
- break;
- }
- char_data = i < char_num ? &char_dat[i].status : NULL;
- //Tell the new map server about this player using Kevin's new auth packet. [Skotlex]
- if (map_fd >= 0 && session[map_fd] && char_data)
- { //Send the map server the auth of this player.
- //Update the "last map" as this is where the player must be spawned on the new map server.
- WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
- char_data->last_point.map = RFIFOW(fd,18);
- char_data->last_point.x = RFIFOW(fd,20);
- char_data->last_point.y = RFIFOW(fd,22);
- char_data->sex = RFIFOB(fd,30);
-
- WFIFOW(map_fd,0) = 0x2afd;
- WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
- WFIFOL(map_fd,4) = RFIFOL(fd, 2); //Account ID
- WFIFOL(map_fd,8) = RFIFOL(fd, 6); //Login1
- WFIFOL(map_fd,16) = RFIFOL(fd,10); //Login2
- WFIFOL(map_fd,12) = (unsigned long)0; //TODO: connect_until_time, how do I figure it out right now?
- memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
- WFIFOSET(map_fd, WFIFOW(map_fd,2));
- data = idb_ensure(online_char_db, RFIFOL(fd, 2), create_online_char_data);
- data->char_id = char_data->char_id;
- data->server = map_id; //Update server where char is.
-
- //Reply with an ack.
- WFIFOW(fd, 0) = 0x2b06;
- memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
- WFIFOSET(fd, 30);
- } else { //Reply with nak
- WFIFOW(fd, 0) = 0x2b06;
- memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
- WFIFOL(fd, 6) = 0; //Set login1 to 0.
- WFIFOSET(fd, 30);
- }
- RFIFOSKIP(fd, 35);
+ {
+ unsigned short name;
+ int map_id, map_fd = -1;
+ struct online_char_data* data;
+ struct mmo_charstatus* char_data;
+
+ name = RFIFOW(fd,18);
+ map_id = search_mapserver(name, ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
+ if (map_id >= 0)
+ map_fd = server_fd[map_id];
+ for(i = 0; i < char_num; i++) {
+ if (char_dat[i].status.account_id == RFIFOL(fd,2) &&
+ char_dat[i].status.char_id == RFIFOL(fd,14))
+ break;
}
- break;
+ char_data = i < char_num ? &char_dat[i].status : NULL;
+ //Tell the new map server about this player using Kevin's new auth packet. [Skotlex]
+ if (map_fd >= 0 && session[map_fd] && char_data)
+ { //Send the map server the auth of this player.
+ //Update the "last map" as this is where the player must be spawned on the new map server.
+ char_data->last_point.map = RFIFOW(fd,18);
+ char_data->last_point.x = RFIFOW(fd,20);
+ char_data->last_point.y = RFIFOW(fd,22);
+ char_data->sex = RFIFOB(fd,30);
+
+ WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
+ WFIFOW(map_fd,0) = 0x2afd;
+ WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
+ WFIFOL(map_fd,4) = RFIFOL(fd, 2); //Account ID
+ WFIFOL(map_fd,8) = RFIFOL(fd, 6); //Login1
+ WFIFOL(map_fd,16) = RFIFOL(fd,10); //Login2
+ WFIFOL(map_fd,12) = (unsigned long)0; //TODO: connect_until_time, how do I figure it out right now?
+ memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
+ WFIFOSET(map_fd, WFIFOW(map_fd,2));
+ data = idb_ensure(online_char_db, RFIFOL(fd, 2), create_online_char_data);
+ data->char_id = char_data->char_id;
+ data->server = map_id; //Update server where char is.
+
+ //Reply with an ack.
+ WFIFOHEAD(fd,30);
+ WFIFOW(fd,0) = 0x2b06;
+ memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
+ WFIFOSET(fd,30);
+ } else { //Reply with nak
+ WFIFOHEAD(fd,30);
+ WFIFOW(fd,0) = 0x2b06;
+ memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
+ WFIFOL(fd,6) = 0; //Set login1 to 0.
+ WFIFOSET(fd,30);
+ }
+ RFIFOSKIP(fd,35);
+ }
+ break;
case 0x2b08: // char name check
if (RFIFOREST(fd) < 6)
@@ -2921,7 +2966,7 @@ int parse_frommap(int fd)
memcpy(WFIFOP(fd,6), unknown_char_name, NAME_LENGTH);
WFIFOSET(fd,6+NAME_LENGTH);
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x2b0a: // request to become GM
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -2940,29 +2985,30 @@ int parse_frommap(int fd)
WFIFOSET(fd,10);
}
RFIFOSKIP(fd, RFIFOW(fd,2));
- break;
+ break;
case 0x2b0c: // Map server send information to change an email of an account -> login-server
if (RFIFOREST(fd) < 86)
return 0;
if (login_fd > 0) { // don't send request if no login-server
WFIFOHEAD(login_fd,86);
- memcpy(WFIFOP(login_fd,0), RFIFOP(fd,0), 86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
+ memcpy(WFIFOP(login_fd,0), RFIFOP(fd,0),86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
WFIFOW(login_fd,0) = 0x2722;
WFIFOSET(login_fd,86);
}
RFIFOSKIP(fd, 86);
- break;
+ break;
case 0x2b0e: // Request from map-server to change a char's status (all operations are transmitted to login-server)
if (RFIFOREST(fd) < 44)
return 0;
- {
+ {
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-1);
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
@@ -2981,7 +3027,6 @@ int parse_frommap(int fd)
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);
-// printf("char : status -> login: account %d, status: %d \n", char_dat[i].account_id, 5);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -3000,8 +3045,6 @@ int parse_frommap(int fd)
WFIFOW(login_fd,14) = RFIFOW(fd,40); // minute
WFIFOW(login_fd,16) = RFIFOW(fd,42); // second
WFIFOSET(login_fd,18);
-// printf("char : status -> login: account %d, ban: %dy %dm %dd %dh %dmn %ds\n",
-// char_dat[i].account_id, (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), (short)RFIFOW(fd,38), (short)RFIFOW(fd,40), (short)RFIFOW(fd,42));
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -3015,7 +3058,6 @@ int parse_frommap(int fd)
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);
-// printf("char : status -> login: account %d, status: %d \n", char_dat[i].account_id, 0);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -3028,7 +3070,6 @@ int parse_frommap(int fd)
WFIFOW(login_fd, 0) = 0x272a;
WFIFOL(login_fd, 2) = char_dat[i].status.account_id; // account value
WFIFOSET(login_fd,6);
-// printf("char : status -> login: account %d, unban request\n", char_dat[i].account_id);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -3041,7 +3082,6 @@ int parse_frommap(int fd)
WFIFOW(login_fd, 0) = 0x2727;
WFIFOL(login_fd, 2) = char_dat[i].status.account_id; // account value
WFIFOSET(login_fd,6);
-// printf("char : status -> login: account %d, change sex request\n", char_dat[i].account_id);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -3059,102 +3099,104 @@ int parse_frommap(int fd)
//WFIFOSET(fd, 34);
WFIFOSET(fd, 10+NAME_LENGTH);
}
+
RFIFOSKIP(fd, 44);
- break;
- }
+ }
+ break;
// case 0x2b0f: Not used anymore, available for future use
case 0x2b10: // Update and send fame ranking list
if (RFIFOREST(fd) < 12)
return 0;
+ {
+ int cid = RFIFOL(fd, 2);
+ int fame = RFIFOL(fd, 6);
+ char type = RFIFOB(fd, 10);
+ char pos = RFIFOB(fd, 11);
+ int size;
+ struct fame_list *list = NULL;
+
+ switch(type) {
+ case 1:
+ size = fame_list_size_smith;
+ list = smith_fame_list;
+ break;
+ case 2:
+ size = fame_list_size_chemist;
+ list = chemist_fame_list;
+ break;
+ case 3:
+ size = fame_list_size_taekwon;
+ list = taekwon_fame_list;
+ break;
+ default:
+ size = 0;
+ break;
+ }
+ if(!size) break; //No list.
+ if(pos)
{
- int cid = RFIFOL(fd, 2);
- int fame = RFIFOL(fd, 6);
- char type = RFIFOB(fd, 10);
- char pos = RFIFOB(fd, 11);
- int size;
- struct fame_list *list = NULL;
- RFIFOSKIP(fd,12);
-
- switch(type) {
- case 1:
- size = fame_list_size_smith;
- list = smith_fame_list;
- break;
- case 2:
- size = fame_list_size_chemist;
- list = chemist_fame_list;
- break;
- case 3:
- size = fame_list_size_taekwon;
- list = taekwon_fame_list;
- break;
- default:
- size = 0;
- break;
- }
- if(!size) break; //No list.
- if(pos)
- {
- pos--; //Convert from pos to index.
- if(
- (pos == 0 || fame < list[pos-1].fame) &&
- (pos == size-1 || fame > list[pos+1].fame)
- ) { //No change in order.
- list[(int)pos].fame = fame;
- char_update_fame_list(type, pos, fame);
- break;
- }
- // If the player's already in the list, remove the entry and shift the following ones 1 step up
- memmove(list+pos, list+pos+1, (size-pos-1) * sizeof(struct fame_list));
- //Clear out last entry.
- list[size-1].id = 0;
- list[size-1].fame = 0;
+ pos--; //Convert from pos to index.
+ if(
+ (pos == 0 || fame < list[pos-1].fame) &&
+ (pos == size-1 || fame > list[pos+1].fame)
+ ) { //No change in order.
+ list[(int)pos].fame = fame;
+ char_update_fame_list(type, pos, fame);
+ break;
}
-
- // Find the position where the player has to be inserted
- for(i = 0; i < size && fame < list[i].fame; i++);
- if(i >= size) break;//Out of ranking.
- // When found someone with less or as much fame, insert just above
- memmove(list+i+1, list+i, (size-i-1) * sizeof(struct fame_list));
- list[i].id = cid;
- list[i].fame = fame;
- // Look for the player's name
- for(j = 0; j < char_num && char_dat[j].status.char_id != id; j++);
- if(j < char_num)
- strncpy(list[i].name, char_dat[j].status.name, NAME_LENGTH);
- else //Not found??
- strncpy(list[i].name, "Unknown", NAME_LENGTH);
- char_send_fame_list(-1);
+ // If the player's already in the list, remove the entry and shift the following ones 1 step up
+ memmove(list+pos, list+pos+1, (size-pos-1) * sizeof(struct fame_list));
+ //Clear out last entry.
+ list[size-1].id = 0;
+ list[size-1].fame = 0;
}
- break;
+
+ // Find the position where the player has to be inserted
+ for(i = 0; i < size && fame < list[i].fame; i++);
+ if(i >= size) break;//Out of ranking.
+ // When found someone with less or as much fame, insert just above
+ memmove(list+i+1, list+i, (size-i-1) * sizeof(struct fame_list));
+ list[i].id = cid;
+ list[i].fame = fame;
+ // Look for the player's name
+ for(j = 0; j < char_num && char_dat[j].status.char_id != id; j++);
+ if(j < char_num)
+ strncpy(list[i].name, char_dat[j].status.name, NAME_LENGTH);
+ else //Not found??
+ strncpy(list[i].name, "Unknown", NAME_LENGTH);
+ char_send_fame_list(-1);
+
+ RFIFOSKIP(fd,12);
+ }
+ break;
case 0x2b16: // Receive rates [Wizputer]
if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,8))
return 0;
// Txt doesn't need this packet, so just skip it
RFIFOSKIP(fd,RFIFOW(fd,8));
- break;
+ break;
case 0x2b17: // Character disconnected set online 0 [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6));
RFIFOSKIP(fd,10);
- break;
+ break;
case 0x2b18: // Reset all chars to offline [Wizputer]
set_all_offline(id);
RFIFOSKIP(fd,2);
- break;
+ break;
case 0x2b19: // Character set online [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
set_char_online(id, RFIFOL(fd,2),RFIFOL(fd,6));
RFIFOSKIP(fd,10);
- break;
+ break;
case 0x2b1a: // Build and send fame ranking lists [DracoRPG]
if (RFIFOREST(fd) < 2)
@@ -3162,7 +3204,7 @@ int parse_frommap(int fd)
char_read_fame_list();
char_send_fame_list(-1);
RFIFOSKIP(fd,2);
- break;
+ break;
case 0x2b1c: //Request to save status change data. [Skotlex]
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -3175,6 +3217,7 @@ int parse_frommap(int fd)
aid = RFIFOL(fd, 4);
cid = RFIFOL(fd, 8);
count = RFIFOW(fd, 12);
+
data = status_search_scdata(aid, cid);
if (data->count != count)
{
@@ -3185,31 +3228,30 @@ int parse_frommap(int fd)
memcpy (&data->data[i], RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data));
#endif
RFIFOSKIP(fd, RFIFOW(fd, 2));
- break;
}
+ break;
case 0x2736: // ip address update
if (RFIFOREST(fd) < 6) return 0;
server[id].ip = ntohl(RFIFOL(fd, 2));
ShowInfo("Updated IP address of map-server #%d to %d.%d.%d.%d.\n", id, CONVIP(server[id].ip));
RFIFOSKIP(fd,6);
- break;
+ break;
default:
- // inter server処理に渡す
- {
- int r = inter_parse_frommap(fd);
- if (r == 1) // 処理できた
- break;
- if (r == 2) // パケット長が足りない
- return 0;
- }
- // inter server処理でもない場合は切断
+ // inter server - packet
+ {
+ int r = inter_parse_frommap(fd);
+ if (r == 1) break; // processed
+ if (r == 2) return 0; // need more packet
+
+ // no inter server packet. no char server packet -> disconnect
ShowError("Unknown packet 0x%04x from map server, disconnecting.\n", RFIFOW(fd,0));
set_eof(fd);
return 0;
}
- }
+ } // switch
+ } // while
return 0;
}
@@ -3232,7 +3274,8 @@ int search_mapserver(unsigned short map, uint32 ip, uint16 port)
}
// char_mapifの初期化処理(現在はinter_mapif初期化のみ)
-static int char_mapif_init(int fd) {
+static int char_mapif_init(int fd)
+{
return inter_mapif_init(fd);
}
@@ -3261,14 +3304,12 @@ int lan_subnetcheck(uint32 ip)
int parse_char(int fd)
{
int i, ch;
- unsigned short cmd;
char email[40];
+ unsigned short cmd;
int map_fd;
struct char_session_data *sd;
uint32 ipl = session[fd]->client_addr;
- RFIFOHEAD(fd);
-
sd = (struct char_session_data*)session[fd]->session_data;
if(login_fd < 0)
@@ -3306,19 +3347,18 @@ int parse_char(int fd)
//For use in packets that depend on an sd being present [Skotlex]
#define FIFOSD_CHECK(rest) { if(RFIFOREST(fd) < rest) return 0; if (sd==NULL) { RFIFOSKIP(fd,rest); return 0; } }
- switch(cmd){
+ switch(cmd) {
case 0x20b: //20040622暗号化ragexe対応
if (RFIFOREST(fd) < 19)
return 0;
RFIFOSKIP(fd,19);
- break;
+ break;
case 0x65: // 接続要求
if (RFIFOREST(fd) < 17)
return 0;
{
int GM_value;
- WFIFOHEAD(fd,4);
if (sd) {
//Received again auth packet for already authentified account?? Discard it.
@@ -3340,6 +3380,7 @@ int parse_char(int fd)
sd->login_id2 = RFIFOL(fd,10);
sd->sex = RFIFOB(fd,16);
// send back account_id
+ WFIFOHEAD(fd,4);
WFIFOL(fd,0) = RFIFOL(fd,2);
WFIFOSET(fd,4);
// search authentification
@@ -3371,15 +3412,17 @@ int parse_char(int fd)
WFIFOSET(fd,3);
}
}
- }
+
RFIFOSKIP(fd,17);
- break;
+ }
+ break;
case 0x66: // char select
FIFOSD_CHECK(3);
{
int char_num = RFIFOB(fd,2);
struct mmo_charstatus *cd;
+
RFIFOSKIP(fd,3);
// if we activated email creation and email is default email
@@ -3485,32 +3528,31 @@ int parse_char(int fd)
//Send NEW auth packet [Kevin]
if ((map_fd = server_fd[i]) < 1 || session[map_fd] == NULL)
{
- WFIFOHEAD(fd,3);
ShowError("parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i);
server_fd[i] = -1;
memset(&server[i], 0, sizeof(struct mmo_map_server));
//Send server closed.
+ WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
break;
}
- { //Send auth to server.
- WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
- WFIFOW(map_fd,0) = 0x2afd;
- WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
- WFIFOL(map_fd,4) = auth_fifo[auth_fifo_pos].account_id;
- WFIFOL(map_fd,8) = auth_fifo[auth_fifo_pos].login_id1;
- WFIFOL(map_fd,16) = auth_fifo[auth_fifo_pos].login_id2;
- WFIFOL(map_fd,12) = (unsigned long)auth_fifo[auth_fifo_pos].connect_until_time;
- memcpy(WFIFOP(map_fd,20), cd, sizeof(struct mmo_charstatus));
- WFIFOSET(map_fd, WFIFOW(map_fd,2));
- }
+ //Send auth to server.
+ WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
+ WFIFOW(map_fd,0) = 0x2afd;
+ WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
+ WFIFOL(map_fd,4) = auth_fifo[auth_fifo_pos].account_id;
+ WFIFOL(map_fd,8) = auth_fifo[auth_fifo_pos].login_id1;
+ WFIFOL(map_fd,16) = auth_fifo[auth_fifo_pos].login_id2;
+ WFIFOL(map_fd,12) = (unsigned long)auth_fifo[auth_fifo_pos].connect_until_time;
+ memcpy(WFIFOP(map_fd,20), cd, sizeof(struct mmo_charstatus));
+ WFIFOSET(map_fd, WFIFOW(map_fd,2));
set_char_online(i, cd->char_id, cd->account_id);
auth_fifo_pos++;
- break;
}
+ break;
case 0x67: // make new
FIFOSD_CHECK(37);
@@ -3530,34 +3572,34 @@ int parse_char(int fd)
case -2: WFIFOB(fd,2) = 0x02; break;
case -3: WFIFOB(fd,2) = 0x01; break;
}
- WFIFOSET(fd, 3);
- RFIFOSKIP(fd, 37);
+ WFIFOSET(fd,3);
+ RFIFOSKIP(fd,37);
break;
}
- { //Send to player.
- int len;
- WFIFOHEAD(fd,110);
- WFIFOW(fd,0) = 0x6d;
- len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status);
- WFIFOSET(fd,len);
- RFIFOSKIP(fd,37);
- }
+ { //Send to player.
+ int len;
+ WFIFOHEAD(fd,110);
+ WFIFOW(fd,0) = 0x6d;
+ len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status);
+ WFIFOSET(fd,len);
+ }
+
for(ch = 0; ch < MAX_CHARS; ch++) {
if (sd->found_char[ch] == -1) {
sd->found_char[ch] = i;
break;
}
}
- break;
+
+ RFIFOSKIP(fd,37);
+ break;
case 0x68: // delete char
FIFOSD_CHECK(46);
{
int cid = RFIFOL(fd,2);
- struct mmo_charstatus *cs = NULL;
- WFIFOHEAD(fd,46);
- WFIFOHEAD(login_fd,46);
+ struct mmo_charstatus* cs = NULL;
ShowInfo(CL_RED" Request Char Deletion:"CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid);
memcpy(email, RFIFOP(fd,6), 40);
RFIFOSKIP(fd,46);
@@ -3570,9 +3612,10 @@ int parse_char(int fd)
if (email_creation != 0 && strcmp(sd->email, "a@a.com") == 0 && login_fd > 0) { // to modify an e-mail, login-server must be online
// if sended email is incorrect e-mail
if (strcmp(email, "a@a.com") == 0) {
- WFIFOW(fd, 0) = 0x70;
- WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address
- WFIFOSET(fd, 3);
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x70;
+ WFIFOB(fd,2) = 0; // 00 = Incorrect Email address
+ WFIFOSET(fd,3);
break;
}
// we change the packet to set it like selection.
@@ -3581,21 +3624,23 @@ int parse_char(int fd)
// we save new e-mail
memcpy(sd->email, email, 40);
// we send new e-mail to login-server ('online' login-server is checked before)
+ WFIFOHEAD(login_fd,46);
WFIFOW(login_fd,0) = 0x2715;
WFIFOL(login_fd,2) = sd->account_id;
memcpy(WFIFOP(login_fd, 6), email, 40);
WFIFOSET(login_fd,46);
// change value to put new packet (char selection)
RFIFOSKIP(fd,-3); //FIXME: Will this work? Messing with the received buffer is ugly anyway...
- RFIFOW(fd, 0) = 0x66;
- RFIFOB(fd, 2) = char_dat[sd->found_char[i]].status.char_num;
+ RFIFOW(fd,0) = 0x66;
+ RFIFOB(fd,2) = char_dat[sd->found_char[i]].status.char_num;
// not send packet, it's modify of actual packet
break;
}
if (i == MAX_CHARS) {
- WFIFOW(fd, 0) = 0x70;
- WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address
- WFIFOSET(fd, 3);
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x70;
+ WFIFOB(fd,2) = 0; // 00 = Incorrect Email address
+ WFIFOSET(fd,3);
}
break;
}
@@ -3603,9 +3648,10 @@ int parse_char(int fd)
// otherwise, we delete the character
if (strcmpi(email, sd->email) != 0) { // if it's an invalid email
- WFIFOW(fd, 0) = 0x70;
- WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address
- WFIFOSET(fd, 3);
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x70;
+ WFIFOB(fd,2) = 0; // 00 = Incorrect Email address
+ WFIFOSET(fd,3);
break;
}
@@ -3614,6 +3660,7 @@ int parse_char(int fd)
if (char_dat[sd->found_char[i]].status.char_id == cid) break;
}
if (i == MAX_CHARS) { // Such a character does not exist in the account
+ WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x70;
WFIFOB(fd,2) = 0;
WFIFOSET(fd,3);
@@ -3645,63 +3692,63 @@ int parse_char(int fd)
for(ch = i; ch < MAX_CHARS-1; ch++)
sd->found_char[ch] = sd->found_char[ch+1];
sd->found_char[MAX_CHARS-1] = -1;
+ WFIFOHEAD(fd,2);
WFIFOW(fd,0) = 0x6f;
WFIFOSET(fd,2);
- break;
}
+ break;
case 0x2af8: // login as map-server
if (RFIFOREST(fd) < 60)
return 0;
{
- char *l_user = RFIFOP(fd,2);
- char *l_pass = RFIFOP(fd,26);
- WFIFOHEAD(fd,4+5*GM_num);
+ char* l_user = RFIFOP(fd,2);
+ char* l_pass = RFIFOP(fd,26);
l_user[23] = '\0';
l_pass[23] = '\0';
- WFIFOW(fd,0) = 0x2af9;
for(i = 0; i < MAX_MAP_SERVERS; i++) {
if (server_fd[i] <= 0)
break;
}
- if (i == MAX_MAP_SERVERS ||
- strcmp(l_user, userid) ||
- strcmp(l_pass, passwd)) {
+ if (i == MAX_MAP_SERVERS || strcmp(l_user, userid) || strcmp(l_pass, passwd)) {
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x2af9;
WFIFOB(fd,2) = 3;
WFIFOSET(fd,3);
- RFIFOSKIP(fd,60);
} else {
- int len;
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x2af9;
WFIFOB(fd,2) = 0;
WFIFOSET(fd,3);
+
session[fd]->func_parse = parse_frommap;
server_fd[i] = fd;
server[i].ip = ntohl(RFIFOL(fd,54));
server[i].port = ntohs(RFIFOW(fd,58));
server[i].users = 0;
memset(server[i].map, 0, sizeof(server[i].map));
- RFIFOSKIP(fd,60);
realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
char_mapif_init(fd);
// send gm acccounts level to map-servers
- len = 4;
+ WFIFOHEAD(fd,4+5*GM_num);
WFIFOW(fd,0) = 0x2b15;
for(i = 0; i < GM_num; i++) {
- WFIFOL(fd,len) = gm_account[i].account_id;
- WFIFOB(fd,len+4) = (unsigned char)gm_account[i].level;
- len += 5;
+ WFIFOL(fd,4+5*i) = gm_account[i].account_id;
+ WFIFOB(fd,4+5*i+4) = (unsigned char)gm_account[i].level;
}
- WFIFOW(fd,2) = len;
- WFIFOSET(fd,len);
+ WFIFOW(fd,2) = 4+5*GM_num;
+ WFIFOSET(fd,WFIFOW(fd,2));
}
- break;
+
+ RFIFOSKIP(fd,60);
}
+ break;
case 0x187: // Alive?
if (RFIFOREST(fd) < 6)
return 0;
RFIFOSKIP(fd, 6);
- break;
+ break;
case 0x7530: // Athena info get
{
@@ -3718,12 +3765,14 @@ int parse_char(int fd)
RFIFOSKIP(fd,2);
return 0;
}
+
case 0x7532: // disconnect(default also disconnect)
default:
set_eof(fd);
return 0;
}
}
+
RFIFOFLUSH(fd);
return 0;
}
@@ -3759,7 +3808,8 @@ int parse_console(char* buf)
}
// 全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す)
-int mapif_sendall(unsigned char *buf, unsigned int len) {
+int mapif_sendall(unsigned char *buf, unsigned int len)
+{
int i, c;
c = 0;
@@ -3777,7 +3827,8 @@ int mapif_sendall(unsigned char *buf, unsigned int len) {
}
// 自分以外の全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す)
-int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) {
+int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
+{
int i, c;
c = 0;
@@ -3794,7 +3845,8 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) {
return c;
}
// MAPサーバーにデータ送信(map鯖生存確認有り)
-int mapif_send(int fd, unsigned char *buf, unsigned int len) {
+int mapif_send(int fd, unsigned char *buf, unsigned int len)
+{
int i;
if (fd >= 0) {
@@ -3810,7 +3862,8 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len) {
return 0;
}
-int send_users_tologin(int tid, unsigned int tick, int id, int data) {
+int send_users_tologin(int tid, unsigned int tick, int id, int data)
+{
int users = count_users();
unsigned char buf[16];
@@ -3829,7 +3882,8 @@ int send_users_tologin(int tid, unsigned int tick, int id, int data) {
return 0;
}
-static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap) {
+static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap)
+{
struct online_char_data* character = (struct online_char_data*)data;
int *i = va_arg(ap, int*);
int count = va_arg(ap, int);
@@ -3844,7 +3898,8 @@ static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap) {
return 0;
}
-int send_accounts_tologin(int tid, unsigned int tick, int id, int data) {
+int send_accounts_tologin(int tid, unsigned int tick, int id, int data)
+{
int users = count_users(), i=0;
if (login_fd > 0 && session[login_fd]) {
@@ -3873,7 +3928,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data)
}
session[login_fd]->func_parse = parse_tologin;
realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
- {
+
WFIFOHEAD(login_fd,86);
WFIFOW(login_fd,0) = 0x2710;
memcpy(WFIFOP(login_fd,2), userid, 24);
@@ -3886,7 +3941,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data)
WFIFOW(login_fd,82) = char_maintenance;
WFIFOW(login_fd,84) = char_new_display; //only display (New) if they want to [Kevin]
WFIFOSET(login_fd,86);
- }
+
return 1;
}
@@ -3909,8 +3964,8 @@ static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int dat
// Reading Lan Support configuration
// Rewrote: Anvanced subnet check [LuzZza]
//----------------------------------
-int char_lan_config_read(const char *lancfgName) {
-
+int char_lan_config_read(const char *lancfgName)
+{
FILE *fp;
int line_num = 0;
char line[1024], w1[64], w2[64], w3[64], w4[64];
@@ -3962,7 +4017,8 @@ int char_lan_config_read(const char *lancfgName) {
}
#endif //TXT_SQL_CONVERT
-int char_config_read(const char *cfgName) {
+int char_config_read(const char *cfgName)
+{
char line[1024], w1[1024], w2[1024];
FILE* fp = fopen(cfgName, "r");
@@ -4160,7 +4216,8 @@ int chardb_final(int key, void* data, va_list va)
aFree(data);
return 0;
}
-void do_final(void) {
+void do_final(void)
+{
ShowStatus("Terminating server.\n");
// write online players files with no player
online_char_db->clear(online_char_db, NULL); //clean the db...
@@ -4193,7 +4250,8 @@ void do_final(void) {
// Function called when the server
// has received a crash signal.
//------------------------------
-void do_abort(void) {
+void do_abort(void)
+{
}
void set_server_type(void)
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 213091224..eeca0209f 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -185,19 +185,10 @@ struct online_char_data {
struct dbt *online_char_db; //Holds all online characters.
-#ifndef SQL_DEBUG
-
-#define mysql_query(_x, _y) mysql_real_query(_x, _y, strlen(_y)) //supports ' in names and runs faster [Kevin]
-
-#else
-
-#define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-
-#endif
-
static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int data);
-static void * create_online_char_data(DBKey key, va_list args) {
+static void * create_online_char_data(DBKey key, va_list args)
+{
struct online_char_data* character;
character = aCalloc(1, sizeof(struct online_char_data));
character->account_id = key.i;
@@ -212,8 +203,10 @@ static void * create_online_char_data(DBKey key, va_list args) {
// Set Character online/offline [Wizputer]
//-------------------------------------------------
-void set_char_online(int map_id, int char_id, int account_id) {
+void set_char_online(int map_id, int char_id, int account_id)
+{
struct online_char_data* character;
+
if ( char_id != 99 ) {
sprintf(tmp_sql, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'",char_db,char_id);
if (mysql_query(&mysql_handle, tmp_sql)) {
@@ -224,7 +217,7 @@ void set_char_online(int map_id, int char_id, int account_id) {
if (max_account_id < account_id || max_char_id < char_id)
{ //Notify map-server of the new max IDs [Skotlex]
if (account_id > max_account_id)
- max_account_id = account_id;
+ max_account_id = account_id;
if (char_id > max_char_id)
max_char_id = char_id;
mapif_send_maxid(max_account_id, max_char_id);
@@ -242,9 +235,11 @@ void set_char_online(int map_id, int char_id, int account_id) {
character->account_id, character->char_id, character->server, map_id, account_id, char_id);
mapif_disconnectplayer(server_fd[character->server], character->account_id, character->char_id, 2);
}
+
character->char_id = (char_id==99)?-1:char_id;
character->server = (char_id==99)?-1:map_id;
- if(character->waiting_disconnect != -1){
+
+ if(character->waiting_disconnect != -1) {
delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
character->waiting_disconnect = -1;
}
@@ -263,7 +258,8 @@ void set_char_online(int map_id, int char_id, int account_id) {
}
}
-void set_char_offline(int char_id, int account_id) {
+void set_char_offline(int char_id, int account_id)
+{
struct mmo_charstatus *cp;
struct online_char_data* character;
@@ -294,7 +290,7 @@ void set_char_offline(int char_id, int account_id) {
}
}
- if (login_fd > 0 && !session[login_fd]->eof)
+ if (login_fd > 0 && !session[login_fd]->eof)
{
WFIFOHEAD(login_fd,6);
WFIFOW(login_fd,0) = 0x272c;
@@ -303,7 +299,8 @@ void set_char_offline(int char_id, int account_id) {
}
}
-static int char_db_setoffline(DBKey key, void* data, va_list ap) {
+static int char_db_setoffline(DBKey key, void* data, va_list ap)
+{
struct online_char_data* character = (struct online_char_data*)data;
int server = va_arg(ap, int);
if (server == -1) {
@@ -318,9 +315,11 @@ static int char_db_setoffline(DBKey key, void* data, va_list ap) {
return 0;
}
-static int char_db_kickoffline(DBKey key, void* data, va_list ap) {
+static int char_db_kickoffline(DBKey key, void* data, va_list ap)
+{
struct online_char_data* character = (struct online_char_data*)data;
int server = va_arg(ap, int);
+
if (server > -1 && character->server != server)
return 0;
@@ -334,7 +333,8 @@ static int char_db_kickoffline(DBKey key, void* data, va_list ap) {
return 1;
}
-void set_all_offline(int id) {
+void set_all_offline(int id)
+{
if (id < 0)
ShowNotice("Sending all users offline.\n");
else
@@ -349,7 +349,8 @@ void set_all_offline(int id) {
WFIFOSET(login_fd,2);
}
-void set_all_offline_sql(void) {
+void set_all_offline_sql(void)
+{
//Set all players to 'OFFLINE'
sprintf(tmp_sql, "UPDATE `%s` SET `online` = '0'", char_db);
if(mysql_query(&mysql_handle, tmp_sql)){
@@ -372,8 +373,8 @@ void set_all_offline_sql(void) {
// Determine if an account (id) is a GM account
// and returns its level (or 0 if it isn't a GM account or if not found)
//----------------------------------------------------------------------
-// Removed since nothing GM related goes on in the char server [CLOWNISIUS]
-int isGM(int account_id) {
+int isGM(int account_id)
+{
int i;
for(i = 0; i < GM_num; i++)
@@ -382,7 +383,8 @@ int isGM(int account_id) {
return 0;
}
-void read_gm_account(void) {
+void read_gm_account(void)
+{
if(!char_gm_read)
return;
@@ -409,7 +411,8 @@ void read_gm_account(void) {
mapif_send_gmaccounts();
}
#endif //TXT_SQL_CONVERT
-int compare_item(struct item *a, struct item *b) {
+int compare_item(struct item *a, struct item *b)
+{
if(a->id == b->id &&
a->nameid == b->nameid &&
@@ -427,7 +430,8 @@ int compare_item(struct item *a, struct item *b) {
}
#ifndef TXT_SQL_CONVERT
-static void* create_charstatus(DBKey key, va_list args) {
+static void* create_charstatus(DBKey key, va_list args)
+{
struct mmo_charstatus *cp;
cp = (struct mmo_charstatus *) aCalloc(1,sizeof(struct mmo_charstatus));
cp->char_id = key.i;
@@ -1094,7 +1098,8 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
}
//==========================================================================================================
-int mmo_char_sql_init(void) {
+int mmo_char_sql_init(void)
+{
ShowInfo("Begin Initializing.......\n");
char_db_= db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA, sizeof(int));
// memory initialize
@@ -1121,7 +1126,8 @@ int mmo_char_sql_init(void) {
//==========================================================================================================
-int make_new_char_sql(int fd, unsigned char *dat) {
+int make_new_char_sql(int fd, unsigned char *dat)
+{
struct char_session_data *sd;
char name[NAME_LENGTH];
char t_name[NAME_LENGTH*2];
@@ -1551,7 +1557,8 @@ int delete_char_sql(int char_id, int partner_id)
//==========================================================================================================
-int count_users(void) {
+int count_users(void)
+{
int i, users;
if (login_fd > 0 && session[login_fd]){
@@ -1624,7 +1631,8 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
#endif
}
-int mmo_char_send006b(int fd, struct char_session_data *sd) {
+int mmo_char_send006b(int fd, struct char_session_data *sd)
+{
int i, j, found_num = 0;
set_char_online(-1, 99,sd->account_id);
@@ -1716,13 +1724,12 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
mmo_char_send006b(fd, sd);
}
-
int send_accounts_tologin(int tid, unsigned int tick, int id, int data);
-int parse_tologin(int fd) {
+int parse_tologin(int fd)
+{
int i;
struct char_session_data *sd;
- RFIFOHEAD(fd);
// only login-server can have an access to here.
// so, if it isn't the login-server, we disconnect the session.
//session eof check!
@@ -1744,17 +1751,16 @@ int parse_tologin(int fd) {
while(RFIFOREST(fd) >= 2) {
// printf("parse_tologin : %d %d %x\n", fd, RFIFOREST(fd), RFIFOW(fd, 0));
- switch(RFIFOW(fd, 0)){
+ switch(RFIFOW(fd,0)) {
case 0x2711:
if (RFIFOREST(fd) < 3)
return 0;
- if (RFIFOB(fd, 2)) {
+ if (RFIFOB(fd,2)) {
//printf("connect login server error : %d\n", RFIFOB(fd, 2));
ShowError("Can not connect to login-server.\n");
ShowError("The server communication passwords (default s1/p1) are probably invalid.\n");
ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n");
ShowError("The communication passwords are set in map_athena.conf and char_athena.conf\n");
- return 0;
//exit(1); //fixed for server shutdown.
}else {
ShowStatus("Connected to login-server (connection #%d).\n", fd);
@@ -1769,11 +1775,11 @@ int parse_tologin(int fd) {
if (i == MAX_MAP_SERVERS)
ShowStatus("Awaiting maps from map-server.\n");
}
- RFIFOSKIP(fd, 3);
- break;
+ RFIFOSKIP(fd,3);
+ break;
case 0x2713:
- if(RFIFOREST(fd)<51)
+ if (RFIFOREST(fd) < 51)
return 0;
for(i = 0; i < fd_max && !(
@@ -1789,13 +1795,13 @@ int parse_tologin(int fd) {
WFIFOB(i,2) = 0x42;
WFIFOSET(i,3);
} else {
- sd->connect_until_time = (time_t)RFIFOL(fd,47);
memcpy(sd->email, RFIFOP(fd, 7), 40);
+ sd->connect_until_time = (time_t)RFIFOL(fd,47);
char_auth_ok(i, sd);
}
}
RFIFOSKIP(fd,51);
- break;
+ break;
case 0x2717:
if (RFIFOREST(fd) < 50)
@@ -1803,21 +1809,21 @@ int parse_tologin(int fd) {
for(i = 0; i < fd_max; i++) {
if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) {
if (sd->account_id == RFIFOL(fd,2)) {
- memcpy(sd->email, RFIFOP(fd, 6), 40);
- sd->connect_until_time = (time_t)RFIFOL(fd,46);
- break;
+ memcpy(sd->email, RFIFOP(fd,6), 40);
+ sd->connect_until_time = (time_t)RFIFOL(fd,46);
+ break;
}
}
}
RFIFOSKIP(fd,50);
- break;
+ break;
// login-server alive packet
case 0x2718:
if (RFIFOREST(fd) < 2)
return 0;
RFIFOSKIP(fd,2);
- break;
+ break;
// Receiving authentification from Freya-type login server (to avoid char->login->char)
case 0x2719:
@@ -1844,12 +1850,11 @@ int parse_tologin(int fd) {
auth_fifo[i].connect_until_time = 0; // unlimited/unknown time by default (not display in map-server)
auth_fifo[i].ip = ntohl(RFIFOL(fd,14));
RFIFOSKIP(fd,18);
- break;
+ break;
case 0x2721: // gm reply. I don't want to support this function.
if (RFIFOREST(fd) < 10)
return 0;
- RFIFOSKIP(fd, 10);
/* Note that this is the code from char-txt! Even uncommenting it will not work.
printf("0x2721:GM reply\n");
{
@@ -1873,17 +1878,18 @@ int parse_tologin(int fd) {
// printf("char -> map\n");
}
*/
- break;
+ RFIFOSKIP(fd, 10);
+ break;
+
case 0x2723: // changesex reply (modified by [Yor])
if (RFIFOREST(fd) < 7)
return 0;
- {
+ {
int acc, sex;
unsigned char buf[16];
MYSQL_RES* sql_res2;
acc = RFIFOL(fd,2);
sex = RFIFOB(fd,6);
- RFIFOSKIP(fd, 7);
if (acc > 0) {
sprintf(tmp_sql, "SELECT `char_id`,`class`,`skill_point`,`guild_id` FROM `%s` WHERE `account_id` = '%d'",char_db, acc);
if (mysql_query(&mysql_handle, tmp_sql)) {
@@ -1893,105 +1899,106 @@ int parse_tologin(int fd) {
sql_res2 = mysql_store_result(&mysql_handle);
while(sql_res2 && (sql_row = mysql_fetch_row(sql_res2))) {
- int char_id, guild_id, jobclass, skill_point, class_;
- char_id = atoi(sql_row[0]);
- jobclass = atoi(sql_row[1]);
- skill_point = atoi(sql_row[2]);
- guild_id = atoi(sql_row[3]);
- class_ = jobclass;
- if (jobclass == JOB_BARD || jobclass == JOB_DANCER ||
- jobclass == JOB_CLOWN || jobclass == JOB_GYPSY ||
- jobclass == JOB_BABY_BARD || jobclass == JOB_BABY_DANCER) {
- // job modification
- if (jobclass == JOB_BARD || jobclass == JOB_DANCER) {
- class_ = (sex) ? JOB_BARD : JOB_DANCER;
- } else if (jobclass == JOB_CLOWN || jobclass == JOB_GYPSY) {
- class_ = (sex) ? JOB_CLOWN : JOB_GYPSY;
- } else if (jobclass == JOB_BABY_BARD || jobclass == JOB_BABY_DANCER) {
- class_ = (sex) ? JOB_BABY_BARD : JOB_BABY_DANCER;
- }
- // remove specifical skills of classes 19,20 4020,4021 and 4042,4043
- sprintf(tmp_sql, "SELECT `lv` FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id);
- if (mysql_query(&mysql_handle, tmp_sql)) {
- ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
- sql_res = mysql_store_result(&mysql_handle);
- if (sql_res) {
- while(( sql_row = mysql_fetch_row(sql_res))) {
- skill_point += atoi(sql_row[0]);
- }
- mysql_free_result(sql_res);
- }
- sprintf(tmp_sql, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id);
- if (mysql_query(&mysql_handle, tmp_sql)) {
- ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
+ int char_id, guild_id, jobclass, skill_point, class_;
+ char_id = atoi(sql_row[0]);
+ jobclass = atoi(sql_row[1]);
+ skill_point = atoi(sql_row[2]);
+ guild_id = atoi(sql_row[3]);
+ class_ = jobclass;
+ if (jobclass == JOB_BARD || jobclass == JOB_DANCER ||
+ jobclass == JOB_CLOWN || jobclass == JOB_GYPSY ||
+ jobclass == JOB_BABY_BARD || jobclass == JOB_BABY_DANCER) {
+ // job modification
+ if (jobclass == JOB_BARD || jobclass == JOB_DANCER) {
+ class_ = (sex) ? JOB_BARD : JOB_DANCER;
+ } else if (jobclass == JOB_CLOWN || jobclass == JOB_GYPSY) {
+ class_ = (sex) ? JOB_CLOWN : JOB_GYPSY;
+ } else if (jobclass == JOB_BABY_BARD || jobclass == JOB_BABY_DANCER) {
+ class_ = (sex) ? JOB_BABY_BARD : JOB_BABY_DANCER;
}
- // to avoid any problem with equipment and invalid sex, equipment is unequiped.
- sprintf(tmp_sql, "UPDATE `%s` SET `equip` = '0' WHERE `char_id` = '%d'",inventory_db, char_id);
+ // remove specifical skills of classes 19,20 4020,4021 and 4042,4043
+ sprintf(tmp_sql, "SELECT `lv` FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id);
if (mysql_query(&mysql_handle, tmp_sql)) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
- sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d' , `skill_point`='%d' , `weapon`='0' , `shield`='0' , `head_top`='0' , `head_mid`='0' , `head_bottom`='0' WHERE `char_id` = '%d'",char_db, class_, skill_point, char_id);
+ sql_res = mysql_store_result(&mysql_handle);
+ if (sql_res) {
+ while(( sql_row = mysql_fetch_row(sql_res))) {
+ skill_point += atoi(sql_row[0]);
+ }
+ mysql_free_result(sql_res);
+ }
+ sprintf(tmp_sql, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id);
if (mysql_query(&mysql_handle, tmp_sql)) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
-
- if (guild_id) //If there is a guild, update the guild_member data [Skotlex]
- inter_guild_sex_changed(guild_id, acc, char_id, sex);
}
- if (sql_res2)
- mysql_free_result(sql_res2);
- }
- // disconnect player if online on char-server
- for(i = 0; i < fd_max; i++) {
- if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) {
- if (sd->account_id == acc) {
- set_eof(i);
- break;
- }
+ // to avoid any problem with equipment and invalid sex, equipment is unequiped.
+ sprintf(tmp_sql, "UPDATE `%s` SET `equip` = '0' WHERE `char_id` = '%d'",inventory_db, char_id);
+ if (mysql_query(&mysql_handle, tmp_sql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
+ }
+ sprintf(tmp_sql, "UPDATE `%s` SET `class`='%d' , `skill_point`='%d' , `weapon`='0' , `shield`='0' , `head_top`='0' , `head_mid`='0' , `head_bottom`='0' WHERE `char_id` = '%d'",char_db, class_, skill_point, char_id);
+ if (mysql_query(&mysql_handle, tmp_sql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
+ }
+
+ if (guild_id) //If there is a guild, update the guild_member data [Skotlex]
+ inter_guild_sex_changed(guild_id, acc, char_id, sex);
+ }
+ if (sql_res2)
+ mysql_free_result(sql_res2);
+ }
+ // disconnect player if online on char-server
+ for(i = 0; i < fd_max; i++) {
+ if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) {
+ if (sd->account_id == acc) {
+ set_eof(i);
+ break;
}
}
+ }
WBUFW(buf,0) = 0x2b0d;
WBUFL(buf,2) = acc;
WBUFB(buf,6) = sex;
-
mapif_sendall(buf, 7);
- }
- break;
+
+ RFIFOSKIP(fd,7);
+ }
+ break;
// account_reg2変更通知
case 0x2729:
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
- { //Receive account_reg2 registry, forward to map servers.
+ { //Receive account_reg2 registry, forward to map servers.
unsigned char buf[ACCOUNT_REG2_NUM*(256+32+2)+16];
memcpy(buf,RFIFOP(fd,0), RFIFOW(fd,2));
// WBUFW(buf,0) = 0x2b11;
WBUFW(buf,0) = 0x3804; //Map server can now receive all kinds of reg values with the same packet. [Skotlex]
mapif_sendall(buf, WBUFW(buf,2));
RFIFOSKIP(fd, RFIFOW(fd,2));
- }
- break;
+ }
+ break;
// State change of account/ban notification (from login-server) by [Yor]
case 0x2731:
if (RFIFOREST(fd) < 11)
return 0;
// send to all map-servers to disconnect the player
- {
- unsigned char buf[16];
+ {
+ unsigned char buf[11];
WBUFW(buf,0) = 0x2b14;
WBUFL(buf,2) = RFIFOL(fd,2);
WBUFB(buf,6) = RFIFOB(fd,6); // 0: change of statut, 1: ban
WBUFL(buf,7) = RFIFOL(fd,7); // status or final date of a banishment
mapif_sendall(buf, 11);
- }
+ }
// disconnect player if online on char-server
for(i = 0; i < fd_max; i++) {
if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) {
@@ -2002,7 +2009,7 @@ int parse_tologin(int fd) {
}
}
RFIFOSKIP(fd,11);
- break;
+ break;
case 0x2732:
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -2024,95 +2031,93 @@ int parse_tologin(int fd) {
memcpy(buf, RFIFOP(fd,0), RFIFOW(fd,2));
WBUFW(buf,0) = 0x2b15;
mapif_sendall(buf, RFIFOW(fd,2));
+
+ RFIFOSKIP(fd,RFIFOW(fd,2));
}
- RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+ break;
// Receive GM accounts [Freya login server packet by Yor]
case 0x2733:
- // add test here to remember that the login-server is Freya-type
- // sprintf (login_server_type, "Freya");
if (RFIFOREST(fd) < 7)
return 0;
- {
- int new_level = 0;
- for(i = 0; i < GM_num; i++)
- if (gm_account[i].account_id == RFIFOL(fd,2)) {
- if (gm_account[i].level != (int)RFIFOB(fd,6)) {
- gm_account[i].level = (int)RFIFOB(fd,6);
- new_level = 1;
- }
- break;
- }
- // if not found, add it
- if (i == GM_num) {
- // limited to 4000, because we send information to char-servers (more than 4000 GM accounts???)
- // int (id) + int (level) = 8 bytes * 4000 = 32k (limit of packets in windows)
- if (((int)RFIFOB(fd,6)) > 0 && GM_num < 4000) {
- if (GM_num == 0) {
- gm_account = (struct gm_account*)aMalloc(sizeof(struct gm_account));
- } else {
- gm_account = (struct gm_account*)aRealloc(gm_account, sizeof(struct gm_account) * (GM_num + 1));
- }
- gm_account[GM_num].account_id = RFIFOL(fd,2);
- gm_account[GM_num].level = (int)RFIFOB(fd,6);
+ {
+ int new_level = 0;
+ for(i = 0; i < GM_num; i++)
+ if (gm_account[i].account_id == RFIFOL(fd,2)) {
+ if (gm_account[i].level != (int)RFIFOB(fd,6)) {
+ gm_account[i].level = (int)RFIFOB(fd,6);
new_level = 1;
- GM_num++;
- if (GM_num >= 4000)
- ShowWarning("4000 GM accounts found. Next GM accounts are not readed.\n");
}
+ break;
}
- if (new_level == 1) {
- ShowStatus("From login-server: receiving GM account information (%d: level %d).\n", RFIFOL(fd,2), (int)RFIFOB(fd,6));
- mapif_send_gmaccounts();
-
- //create_online_files(); // not change online file for only 1 player (in next timer, that will be done
- // send gm acccounts level to map-servers
+ // if not found, add it
+ if (i == GM_num) {
+ // limited to 4000, because we send information to char-servers (more than 4000 GM accounts???)
+ // int (id) + int (level) = 8 bytes * 4000 = 32k (limit of packets in windows)
+ if (((int)RFIFOB(fd,6)) > 0 && GM_num < 4000) {
+ if (GM_num == 0) {
+ gm_account = (struct gm_account*)aMalloc(sizeof(struct gm_account));
+ } else {
+ gm_account = (struct gm_account*)aRealloc(gm_account, sizeof(struct gm_account) * (GM_num + 1));
+ }
+ gm_account[GM_num].account_id = RFIFOL(fd,2);
+ gm_account[GM_num].level = (int)RFIFOB(fd,6);
+ new_level = 1;
+ GM_num++;
+ if (GM_num >= 4000)
+ ShowWarning("4000 GM accounts found. Next GM accounts are not readed.\n");
}
}
+ if (new_level == 1) {
+ ShowStatus("From login-server: receiving GM account information (%d: level %d).\n", RFIFOL(fd,2), (int)RFIFOB(fd,6));
+ //create_online_files(); // not change online file for only 1 player (in next timer, that will be done
+ // send gm acccounts level to map-servers
+ mapif_send_gmaccounts();
+ }
+
RFIFOSKIP(fd,7);
- break;
+ }
+ break;
//Login server request to kick a character out. [Skotlex]
case 0x2734:
if (RFIFOREST(fd) < 6)
return 0;
- {
- struct online_char_data* character;
- int aid = RFIFOL(fd,2);
- if ((character = idb_get(online_char_db, aid)) != NULL)
- { //Kick out this player.
- if (character->server > -1)
- { //Kick it from the map server it is on.
- mapif_disconnectplayer(server_fd[character->server], character->account_id, character->char_id, 2);
- if (character->waiting_disconnect == -1)
- character->waiting_disconnect = add_timer(gettick()+15000, chardb_waiting_disconnect, character->account_id, 0);
- } else { //Manual kick from char server.
- struct char_session_data *tsd;
- int i;
- for(i = 0; i < fd_max; i++) {
- if (session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid)
- {
- WFIFOHEAD(i,3);
- WFIFOW(i,0) = 0x81;
- WFIFOB(i,2) = 2;
- WFIFOSET(i,3);
- break;
- }
+ {
+ struct online_char_data* character;
+ int aid = RFIFOL(fd,2);
+ if ((character = idb_get(online_char_db, aid)) != NULL)
+ { //Kick out this player.
+ if (character->server > -1)
+ { //Kick it from the map server it is on.
+ mapif_disconnectplayer(server_fd[character->server], character->account_id, character->char_id, 2);
+ if (character->waiting_disconnect == -1)
+ character->waiting_disconnect = add_timer(gettick()+15000, chardb_waiting_disconnect, character->account_id, 0);
+ } else { //Manual kick from char server.
+ struct char_session_data *tsd;
+ int i;
+ for(i = 0; i < fd_max; i++) {
+ if (session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid)
+ {
+ WFIFOHEAD(i,3);
+ WFIFOW(i,0) = 0x81;
+ WFIFOB(i,2) = 2;
+ WFIFOSET(i,3);
+ break;
}
- if (i == fd_max) //Shouldn't happen, but just in case.
- set_char_offline(99, aid);
}
+ if (i == fd_max) //Shouldn't happen, but just in case.
+ set_char_offline(99, aid);
}
- RFIFOSKIP(fd,6);
}
- break;
+ RFIFOSKIP(fd,6);
+ }
+ break;
case 0x2735:
{
unsigned char buf[2];
uint32 new_ip = 0;
- RFIFOSKIP(fd,2);
WBUFW(buf,0) = 0x2b1e;
mapif_sendall(buf, 2);
@@ -2131,21 +2136,24 @@ int parse_tologin(int fd) {
WFIFOL(fd,2) = htonl(char_ip);
WFIFOSET(fd,6);
}
- break;
+
+ RFIFOSKIP(fd,2);
}
+ break;
+
default:
- ShowError("Unknown packet 0x%04x from login server, disconnecting.\n", RFIFOW(fd, 0));
+ ShowError("Unknown packet 0x%04x received from login server, disconnecting.\n", RFIFOW(fd,0));
set_eof(fd);
return 0;
}
}
RFIFOFLUSH(fd);
-
return 0;
}
-int request_accreg2(int account_id, int char_id) {
+int request_accreg2(int account_id, int char_id)
+{
if (login_fd > 0) {
WFIFOHEAD(login_fd,10);
WFIFOW(login_fd,0) = 0x272e;
@@ -2156,8 +2164,10 @@ int request_accreg2(int account_id, int char_id) {
}
return 0;
}
+
//Send packet forward to login-server for account saving
-int save_accreg2(unsigned char* buf, int len) {
+int save_accreg2(unsigned char* buf, int len)
+{
if (login_fd > 0) {
WFIFOHEAD(login_fd,len+4);
memcpy(WFIFOP(login_fd,4), buf, len);
@@ -2243,7 +2253,8 @@ void char_read_fame_list(void)
}
// Send map-servers the fame ranking lists
-int char_send_fame_list(int fd) {
+int char_send_fame_list(int fd)
+{
int i, len = 8;
unsigned char buf[32000];
@@ -2315,7 +2326,6 @@ int parse_frommap(int fd)
{
int i = 0, j = 0;
int id;
- RFIFOHEAD(fd);
// Sometimes fd=0, and it will cause server crash. Don't know why. :(
if (fd <= 0) {
@@ -2357,15 +2367,16 @@ int parse_frommap(int fd)
return 0;
}
- while(RFIFOREST(fd) >= 2) {
- switch(RFIFOW(fd, 0)) {
+ while(RFIFOREST(fd) >= 2)
+ {
+ switch(RFIFOW(fd, 0))
+ {
case 0x2718: // map-server alive packet
RFIFOSKIP(fd,2);
- break;
+ break;
case 0x2af7: // request from map-server to reload GM accounts. Transmission to login-server
- RFIFOSKIP(fd,2);
if(char_gm_read) //Re-read gm accounts.
read_gm_account();
//Send to login request to reload gm accounts.
@@ -2374,14 +2385,13 @@ int parse_frommap(int fd)
WFIFOW(login_fd,0) = 0x2709;
WFIFOSET(login_fd,2);
}
- break;
+ RFIFOSKIP(fd,2);
+ break;
case 0x2afa: // Receiving map names list from the map-server
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
- WFIFOHEAD(fd,3+NAME_LENGTH);
-
memset(server[id].map, 0, sizeof(server[id].map));
j = 0;
for(i = 4; i < RFIFOW(fd,2); i += 4) {
@@ -2396,6 +2406,7 @@ int parse_frommap(int fd)
if (max_account_id != DEFAULT_MAX_ACCOUNT_ID || max_char_id != DEFAULT_MAX_CHAR_ID)
mapif_send_maxid(max_account_id, max_char_id); //Send the current max ids to the server to keep in sync [Skotlex]
+ WFIFOHEAD(fd, 3 + NAME_LENGTH);
WFIFOW(fd,0) = 0x2afb;
WFIFOB(fd,2) = 0;
memcpy(WFIFOP(fd,3), wisp_server_name, NAME_LENGTH); // name for wisp to player
@@ -2436,17 +2447,16 @@ int parse_frommap(int fd)
}
}
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+ break;
case 0x2afc: //Packet command is now used for sc_data request. [Skotlex]
if (RFIFOREST(fd) < 10)
return 0;
{
+#ifdef ENABLE_SC_SAVING
int aid, cid;
aid = RFIFOL(fd,2);
cid = RFIFOL(fd,6);
- RFIFOSKIP(fd, 10);
-#ifdef ENABLE_SC_SAVING
sprintf(tmp_sql, "SELECT type, tick, val1, val2, val3, val4 from `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
scdata_db, aid, cid);
if (mysql_query(&mysql_handle, tmp_sql)) {
@@ -2491,8 +2501,9 @@ int parse_frommap(int fd)
}
}
#endif
- break;
+ RFIFOSKIP(fd, 10);
}
+ break;
case 0x2afe: //set MAP user count
if (RFIFOREST(fd) < 4)
@@ -2529,8 +2540,8 @@ int parse_frommap(int fd)
}
//If any chars remain in -2, they will be cleaned in the cleanup timer.
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
}
+ break;
case 0x2b01: // Receive character data from map-server for saving
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -2566,8 +2577,8 @@ int parse_frommap(int fd)
WFIFOSET(fd,10);
}
RFIFOSKIP(fd,size);
- break;
}
+ break;
case 0x2b02: // req char selection
if (RFIFOREST(fd) < 18)
@@ -2584,88 +2595,86 @@ int parse_frommap(int fd)
auth_fifo[auth_fifo_pos].connect_until_time = 0; // unlimited/unknown time by default (not display in map-server)
auth_fifo[auth_fifo_pos].ip = ntohl(RFIFOL(fd,14));
auth_fifo_pos++;
- {
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x2b03;
WFIFOL(fd,2) = RFIFOL(fd, 2);
WFIFOB(fd,6) = 0;
WFIFOSET(fd,7);
- }
RFIFOSKIP(fd,18);
- break;
+ break;
case 0x2b05: // request "change map server"
if (RFIFOREST(fd) < 35)
return 0;
- {
- unsigned short name;
- int map_id, map_fd = -1;
- struct online_char_data* data;
- struct mmo_charstatus* char_data;
-
- name = RFIFOW(fd,18);
- map_id = search_mapserver(name, ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
- if (map_id >= 0)
- map_fd = server_fd[map_id];
- //Char should just had been saved before this packet, so this should be safe. [Skotlex]
- char_data = uidb_get(char_db_,RFIFOL(fd,14));
- if (char_data == NULL)
- { //Really shouldn't happen.
- mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
- char_data = &char_dat;
- }
- //Tell the new map server about this player using Kevin's new auth packet. [Skotlex]
- if (map_fd>=0 && session[map_fd] && char_data)
- { //Send the map server the auth of this player.
- //Update the "last map" as this is where the player must be spawned on the new map server.
- WFIFOHEAD(fd,30);
- WFIFOHEAD(map_fd,20 + sizeof(struct mmo_charstatus));
- char_data->last_point.map = RFIFOW(fd,18);
- char_data->last_point.x = RFIFOW(fd,20);
- char_data->last_point.y = RFIFOW(fd,22);
- char_data->sex = RFIFOB(fd,30);
-
- WFIFOW(map_fd,0) = 0x2afd;
- WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
- WFIFOL(map_fd,4) = RFIFOL(fd,2); //Account ID
- WFIFOL(map_fd,8) = RFIFOL(fd,6); //Login1
- WFIFOL(map_fd,16) = RFIFOL(fd,10); //Login2
- WFIFOL(map_fd,12) = (unsigned long)0; //TODO: connect_until_time, how do I figure it out right now?
- memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
- WFIFOSET(map_fd, WFIFOW(map_fd,2));
- data = idb_ensure(online_char_db, RFIFOL(fd, 2), create_online_char_data);
- data->char_id = char_data->char_id;
- data->server = map_id; //Update server where char is.
-
- //Reply with an ack.
- WFIFOW(fd,0) = 0x2b06;
- memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
- WFIFOSET(fd,30);
- } else { //Reply with nak
- WFIFOHEAD(fd,30);
- WFIFOW(fd,0) = 0x2b06;
- memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
- WFIFOL(fd,6) = 0; //Set login1 to 0.
- WFIFOSET(fd,30);
- }
- RFIFOSKIP(fd,35);
+ {
+ unsigned short name;
+ int map_id, map_fd = -1;
+ struct online_char_data* data;
+ struct mmo_charstatus* char_data;
+
+ name = RFIFOW(fd,18);
+ map_id = search_mapserver(name, ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
+ if (map_id >= 0)
+ map_fd = server_fd[map_id];
+ //Char should just had been saved before this packet, so this should be safe. [Skotlex]
+ char_data = uidb_get(char_db_,RFIFOL(fd,14));
+ if (char_data == NULL)
+ { //Really shouldn't happen.
+ mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
+ char_data = &char_dat;
}
- break;
+ //Tell the new map server about this player using Kevin's new auth packet. [Skotlex]
+ if (map_fd >= 0 && session[map_fd] && char_data)
+ { //Send the map server the auth of this player.
+ //Update the "last map" as this is where the player must be spawned on the new map server.
+ char_data->last_point.map = RFIFOW(fd,18);
+ char_data->last_point.x = RFIFOW(fd,20);
+ char_data->last_point.y = RFIFOW(fd,22);
+ char_data->sex = RFIFOB(fd,30);
+
+ WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
+ WFIFOW(map_fd,0) = 0x2afd;
+ WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
+ WFIFOL(map_fd,4) = RFIFOL(fd,2); //Account ID
+ WFIFOL(map_fd,8) = RFIFOL(fd,6); //Login1
+ WFIFOL(map_fd,16) = RFIFOL(fd,10); //Login2
+ WFIFOL(map_fd,12) = (unsigned long)0; //TODO: connect_until_time, how do I figure it out right now?
+ memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
+ WFIFOSET(map_fd, WFIFOW(map_fd,2));
+ data = idb_ensure(online_char_db, RFIFOL(fd, 2), create_online_char_data);
+ data->char_id = char_data->char_id;
+ data->server = map_id; //Update server where char is.
+
+ //Reply with an ack.
+ WFIFOHEAD(fd,30);
+ WFIFOW(fd,0) = 0x2b06;
+ memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
+ WFIFOSET(fd,30);
+ } else { //Reply with nak
+ WFIFOHEAD(fd,30);
+ WFIFOW(fd,0) = 0x2b06;
+ memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
+ WFIFOL(fd,6) = 0; //Set login1 to 0.
+ WFIFOSET(fd,30);
+ }
+ RFIFOSKIP(fd,35);
+ }
+ break;
case 0x2b08: // char name check
if (RFIFOREST(fd) < 6)
return 0;
- {
- char name[NAME_LENGTH];
- WFIFOHEAD(fd,30);
- char_loadName((int)RFIFOL(fd,2), name);
- WFIFOW(fd,0) = 0x2b09;
- WFIFOL(fd,2) = RFIFOL(fd,2);
- memcpy(WFIFOP(fd,6), name, NAME_LENGTH);
- WFIFOSET(fd,30);
- RFIFOSKIP(fd,6);
- }
- break;
+ {
+ char name[NAME_LENGTH];
+ char_loadName((int)RFIFOL(fd,2), name);
+ WFIFOHEAD(fd,30);
+ WFIFOW(fd,0) = 0x2b09;
+ WFIFOL(fd,2) = RFIFOL(fd,2);
+ memcpy(WFIFOP(fd,6), name, NAME_LENGTH);
+ WFIFOSET(fd,30);
+ RFIFOSKIP(fd,6);
+ }
+ break;
case 0x2b0a: // request to become GM
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -2678,7 +2687,7 @@ int parse_frommap(int fd)
*/
ShowWarning("packet 0x2ba (become GM) is not supported by the Char-Server.\n");
RFIFOSKIP(fd, RFIFOW(fd, 2));
- break;
+ break;
case 0x2b0c: // Map server send information to change an email of an account -> login-server
if (RFIFOREST(fd) < 86)
@@ -2690,19 +2699,19 @@ int parse_frommap(int fd)
WFIFOSET(login_fd,86);
}
RFIFOSKIP(fd, 86);
- break;
+ break;
case 0x2b0e: // Request from map-server to change a char's status (all operations are transmitted to login-server)
if (RFIFOREST(fd) < 44)
return 0;
- {
+ {
char character_name[NAME_LENGTH], t_name[NAME_LENGTH*2];
int acc = RFIFOL(fd,2); // account_id of who ask (-1 if nobody)
- WFIFOHEAD(fd,34);
memcpy(character_name, RFIFOP(fd,6), NAME_LENGTH);
character_name[NAME_LENGTH-1] = '\0';
jstrescapecpy(t_name, character_name); //Escape string for sql use... [Skotlex]
// 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
@@ -2801,72 +2810,74 @@ int parse_frommap(int fd)
}
mysql_free_result(sql_res);
}
- }
+
RFIFOSKIP(fd, 44);
- break;
+ }
+ break;
// case 0x2b0f: Not used anymore, available for future use
case 0x2b10: // Update and send fame ranking list
if (RFIFOREST(fd) < 12)
return 0;
+ {
+ int cid = RFIFOL(fd, 2);
+ int fame = RFIFOL(fd, 6);
+ char type = RFIFOB(fd, 10);
+ char pos = RFIFOB(fd, 11);
+ int size;
+ struct fame_list *list = NULL;
+
+ switch(type) {
+ case 1:
+ size = fame_list_size_smith;
+ list = smith_fame_list;
+ break;
+ case 2:
+ size = fame_list_size_chemist;
+ list = chemist_fame_list;
+ break;
+ case 3:
+ size = fame_list_size_taekwon;
+ list = taekwon_fame_list;
+ break;
+ default:
+ size = 0;
+ break;
+ }
+ if(!size) break; //No list.
+ if(pos)
{
- int cid = RFIFOL(fd, 2);
- int fame = RFIFOL(fd, 6);
- char type = RFIFOB(fd, 10);
- char pos = RFIFOB(fd, 11);
- int size;
- struct fame_list *list = NULL;
- RFIFOSKIP(fd,12);
-
- switch(type) {
- case 1:
- size = fame_list_size_smith;
- list = smith_fame_list;
- break;
- case 2:
- size = fame_list_size_chemist;
- list = chemist_fame_list;
- break;
- case 3:
- size = fame_list_size_taekwon;
- list = taekwon_fame_list;
- break;
- default:
- size = 0;
- break;
- }
- if(!size) break; //No list.
- if(pos)
- {
- pos--; //Convert from pos to index.
- if(
- (pos == 0 || fame < list[pos-1].fame) &&
- (pos == size-1 || fame > list[pos+1].fame)
- ) { //No change in order.
- list[(int)pos].fame = fame;
- char_update_fame_list(type, pos, fame);
- break;
- }
- // If the player's already in the list, remove the entry and shift the following ones 1 step up
- memmove(list+pos, list+pos+1, (size-pos-1) * sizeof(struct fame_list));
- //Clear out last entry.
- list[size-1].id = 0;
- list[size-1].fame = 0;
+ pos--; //Convert from pos to index.
+ if(
+ (pos == 0 || fame < list[pos-1].fame) &&
+ (pos == size-1 || fame > list[pos+1].fame)
+ ) { //No change in order.
+ list[(int)pos].fame = fame;
+ char_update_fame_list(type, pos, fame);
+ break;
}
-
- // Find the position where the player has to be inserted
- for(i = 0; i < size && fame < list[i].fame; i++);
- if(i >= size) break; //Out of ranking.
- // When found someone with less or as much fame, insert just above
- memmove(list+i+1, list+i, (size-i-1) * sizeof(struct fame_list));
- list[i].id = cid;
- list[i].fame = fame;
- // Look for the player's name
- char_loadName(list[i].id, list[i].name);
- char_send_fame_list(-1);
+ // If the player's already in the list, remove the entry and shift the following ones 1 step up
+ memmove(list+pos, list+pos+1, (size-pos-1) * sizeof(struct fame_list));
+ //Clear out last entry.
+ list[size-1].id = 0;
+ list[size-1].fame = 0;
}
- break;
+
+ // Find the position where the player has to be inserted
+ for(i = 0; i < size && fame < list[i].fame; i++);
+ if(i >= size) break; //Out of ranking.
+ // When found someone with less or as much fame, insert just above
+ memmove(list+i+1, list+i, (size-i-1) * sizeof(struct fame_list));
+ list[i].id = cid;
+ list[i].fame = fame;
+ // Look for the player's name
+ char_loadName(list[i].id, list[i].name);
+ char_send_fame_list(-1);
+
+ RFIFOSKIP(fd,12);
+ }
+ break;
case 0x2b16: // Receive rates [Wizputer]
if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,8))
@@ -2885,27 +2896,27 @@ int parse_frommap(int fd)
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
RFIFOSKIP(fd,RFIFOW(fd,8));
- break;
}
+ break;
case 0x2b17: // Character disconnected set online 0 [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6));
RFIFOSKIP(fd,10);
- break;
+ break;
case 0x2b18: // Reset all chars to offline [Wizputer]
set_all_offline(id);
RFIFOSKIP(fd,2);
- break;
+ break;
case 0x2b19: // Character set online [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
set_char_online(id, RFIFOL(fd,2),RFIFOL(fd,6));
RFIFOSKIP(fd,10);
- break;
+ break;
case 0x2b1a: // Build and send fame ranking lists [DracoRPG]
if (RFIFOREST(fd) < 2)
@@ -2913,9 +2924,9 @@ int parse_frommap(int fd)
char_read_fame_list();
char_send_fame_list(-1);
RFIFOSKIP(fd,2);
- break;
+ break;
- case 0x2b1c: //Request saving sc_data of a player. [Skotlex]
+ case 0x2b1c: //Request to save status change data. [Skotlex]
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{
@@ -2946,30 +2957,30 @@ int parse_frommap(int fd)
}
#endif
RFIFOSKIP(fd, RFIFOW(fd, 2));
- break;
}
+ break;
case 0x2736: // ip address update
if (RFIFOREST(fd) < 6) return 0;
server[id].ip = ntohl(RFIFOL(fd, 2));
ShowInfo("Updated IP address of map-server #%d to %d.%d.%d.%d.\n", id, CONVIP(server[id].ip));
RFIFOSKIP(fd,6);
- break;
+ break;
default:
- // inter server - packet
- {
- int r = inter_parse_frommap(fd);
- if (r == 1) break; // processed
- if (r == 2) return 0; // need more packet
- }
+ // inter server - packet
+ {
+ int r = inter_parse_frommap(fd);
+ if (r == 1) break; // processed
+ if (r == 2) return 0; // need more packet
// no inter server packet. no char server packet -> disconnect
ShowError("Unknown packet 0x%04x from map server, disconnecting.\n", RFIFOW(fd,0));
set_eof(fd);
return 0;
}
- }
+ } // switch
+ } // while
return 0;
}
@@ -2991,7 +3002,8 @@ int search_mapserver(unsigned short map, uint32 ip, uint16 port)
return -1;
}
-int char_mapif_init(int fd) {
+int char_mapif_init(int fd)
+{
return inter_mapif_init(fd);
}
@@ -3026,7 +3038,6 @@ int parse_char(int fd)
int map_fd;
struct char_session_data *sd;
uint32 ipl = session[fd]->client_addr;
- RFIFOHEAD(fd);
sd = (struct char_session_data*)session[fd]->session_data;
@@ -3065,20 +3076,18 @@ int parse_char(int fd)
//For use in packets that depend on an sd being present [Skotlex]
#define FIFOSD_CHECK(rest) { if(RFIFOREST(fd) < rest) return 0; if (sd==NULL) { RFIFOSKIP(fd,rest); return 0; } }
- switch(cmd){
+ switch(cmd) {
case 0x20b: //20040622 encryption ragexe correspondence
if (RFIFOREST(fd) < 19)
return 0;
RFIFOSKIP(fd,19);
- break;
+ break;
case 0x65: // request to connect
ShowInfo("request connect - account_id:%d/login_id1:%d/login_id2:%d\n", RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10));
if (RFIFOREST(fd) < 17)
return 0;
{
- WFIFOHEAD(fd,4);
-
if (sd) {
//Received again auth packet for already authentified account?? Discard it.
//TODO: Perhaps log this as a hack attempt?
@@ -3093,6 +3102,7 @@ int parse_char(int fd)
sd->login_id2 = RFIFOL(fd,10);
sd->sex = RFIFOB(fd,16);
// send back account_id
+ WFIFOHEAD(fd,4);
WFIFOL(fd,0) = RFIFOL(fd,2);
WFIFOSET(fd,4);
// search authentification
@@ -3124,9 +3134,10 @@ int parse_char(int fd)
WFIFOSET(fd,3);
}
}
+
+ RFIFOSKIP(fd,17);
}
- RFIFOSKIP(fd, 17);
- break;
+ break;
case 0x66: // char select
FIFOSD_CHECK(3);
@@ -3495,7 +3506,8 @@ int parse_console(char* buf)
}
// MAP send all
-int mapif_sendall(unsigned char *buf, unsigned int len) {
+int mapif_sendall(unsigned char *buf, unsigned int len)
+{
int i, c;
c = 0;
@@ -3512,7 +3524,8 @@ int mapif_sendall(unsigned char *buf, unsigned int len) {
return c;
}
-int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) {
+int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
+{
int i, c;
c = 0;
@@ -3529,7 +3542,8 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) {
return c;
}
-int mapif_send(int fd, unsigned char *buf, unsigned int len) {
+int mapif_send(int fd, unsigned char *buf, unsigned int len)
+{
int i;
if (fd >= 0) {
@@ -3545,7 +3559,8 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len) {
return 0;
}
-int send_users_tologin(int tid, unsigned int tick, int id, int data) {
+int send_users_tologin(int tid, unsigned int tick, int id, int data)
+{
int users = count_users();
unsigned char buf[16];
@@ -3564,7 +3579,8 @@ int send_users_tologin(int tid, unsigned int tick, int id, int data) {
return 0;
}
-static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap) {
+static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap)
+{
struct online_char_data* character = (struct online_char_data*)data;
int *i = va_arg(ap, int*);
int count = va_arg(ap, int);
@@ -3579,7 +3595,8 @@ static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap) {
return 0;
}
-int send_accounts_tologin(int tid, unsigned int tick, int id, int data) {
+int send_accounts_tologin(int tid, unsigned int tick, int id, int data)
+{
int users = count_users(), i=0;
if (login_fd > 0 && session[login_fd]) {
@@ -3594,7 +3611,8 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, int data) {
return 0;
}
-int check_connect_login_server(int tid, unsigned int tick, int id, int data) {
+int check_connect_login_server(int tid, unsigned int tick, int id, int data)
+{
if (login_fd > 0 && session[login_fd] != NULL)
return 0;
@@ -3607,7 +3625,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data) {
}
session[login_fd]->func_parse = parse_tologin;
realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
- {
+
WFIFOHEAD(login_fd,86);
WFIFOW(login_fd,0) = 0x2710;
memcpy(WFIFOP(login_fd,2), userid, 24);
@@ -3620,7 +3638,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data) {
WFIFOW(login_fd,82) = char_maintenance;
WFIFOW(login_fd,84) = char_new_display; //only display (New) if they want to [Kevin]
WFIFOSET(login_fd,86);
- }
+
return 1;
}
@@ -3643,8 +3661,8 @@ static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int dat
// Reading Lan Support configuration
// Rewrote: Anvanced subnet check [LuzZza]
//----------------------------------
-int char_lan_config_read(const char *lancfgName) {
-
+int char_lan_config_read(const char *lancfgName)
+{
FILE *fp;
int line_num = 0;
char line[1024], w1[64], w2[64], w3[64], w4[64];
@@ -3676,9 +3694,9 @@ int char_lan_config_read(const char *lancfgName) {
if(strcmpi(w1, "subnet") == 0) {
- subnet[subnet_count].mask = ntohl(inet_addr(w2));
- subnet[subnet_count].char_ip = ntohl(inet_addr(w3));
- subnet[subnet_count].map_ip = ntohl(inet_addr(w4));
+ subnet[subnet_count].mask = str2ip(w2);
+ subnet[subnet_count].char_ip = str2ip(w3);
+ subnet[subnet_count].map_ip = str2ip(w4);
subnet[subnet_count].subnet = subnet[subnet_count].char_ip&subnet[subnet_count].mask;
if (subnet[subnet_count].subnet != (subnet[subnet_count].map_ip&subnet[subnet_count].mask)) {
ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4);
@@ -3696,7 +3714,8 @@ int char_lan_config_read(const char *lancfgName) {
}
#endif //TXT_SQL_CONVERT
-void sql_config_read(const char *cfgName){ /* Kalaspuff, to get login_db */
+void sql_config_read(const char *cfgName)
+{
char line[1024], w1[1024], w2[1024];
FILE *fp;
@@ -3796,7 +3815,8 @@ void sql_config_read(const char *cfgName){ /* Kalaspuff, to get login_db */
}
#ifndef TXT_SQL_CONVERT
-int char_config_read(const char *cfgName) {
+int char_config_read(const char *cfgName)
+{
char line[1024], w1[1024], w2[1024];
FILE* fp = fopen(cfgName, "r");
@@ -3863,9 +3883,9 @@ int char_config_read(const char *cfgName) {
char_port = atoi(w2);
} else if (strcmpi(w1, "char_maintenance") == 0) {
char_maintenance = atoi(w2);
- } else if (strcmpi(w1, "char_new")==0){
+ } else if (strcmpi(w1, "char_new") == 0) {
char_new = atoi(w2);
- } else if (strcmpi(w1, "char_new_display")==0){
+ } else if (strcmpi(w1, "char_new_display") == 0) {
char_new_display = atoi(w2);
} else if (strcmpi(w1, "max_connect_user") == 0) {
max_connect_user = atoi(w2);
@@ -3953,7 +3973,8 @@ int char_config_read(const char *cfgName) {
return 0;
}
-void do_final(void) {
+void do_final(void)
+{
ShowInfo("Doing final stage...\n");
//inter_save();
do_final_itemdb();
@@ -3999,7 +4020,8 @@ void do_final(void) {
// Function called when the server
// has received a crash signal.
//------------------------------
-void do_abort(void) {
+void do_abort(void)
+{
}
void set_server_type(void)
@@ -4141,16 +4163,8 @@ int do_init(int argc, char **argv)
return 0;
}
-#undef mysql_query
-
-int debug_mysql_query(char *file, int line, void *mysql, const char *q) {
-#ifdef TWILIGHT
- ShowDebug("sql: %s:%d# %s\n", file, line, q);
-#endif
- return mysql_query((MYSQL *) mysql, q);
-}
-
-int char_child(int parent_id, int child_id) {
+int char_child(int parent_id, int child_id)
+{
int tmp_id = 0;
sprintf (tmp_sql, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id);
if (mysql_query (&mysql_handle, tmp_sql)) {
@@ -4170,7 +4184,8 @@ int char_child(int parent_id, int child_id) {
return 0;
}
-int char_married(int pl1,int pl2) {
+int char_married(int pl1,int pl2)
+{
int tmp_id = 0;
sprintf (tmp_sql, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1);
if (mysql_query (&mysql_handle, tmp_sql)) {
@@ -4190,7 +4205,8 @@ int char_married(int pl1,int pl2) {
return 0;
}
-int char_family(int pl1,int pl2,int pl3) {
+int char_family(int pl1,int pl2,int pl3)
+{
int charid, partnerid, childid;
sprintf (tmp_sql, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, pl1, pl2, pl3);
if (mysql_query (&mysql_handle, tmp_sql)) {
@@ -4234,4 +4250,5 @@ int char_family(int pl1,int pl2,int pl3) {
mysql_free_result (sql_res);
return 0;
}
+
#endif //TXT_SQL_CONVERT
diff --git a/src/char_sql/char.h b/src/char_sql/char.h
index 2f3db1216..b77fb596c 100644
--- a/src/char_sql/char.h
+++ b/src/char_sql/char.h
@@ -101,8 +101,6 @@ extern struct gm_account *gm_account;
extern int guild_exp_rate;
extern int log_inter;
-extern int debug_mysql_query(char *file, int line, void *mysql, const char *q);
-
//Exported for use in the TXT-SQL converter.
int mmo_char_tosql(int char_id, struct mmo_charstatus *p);
void sql_config_read(const char *cfgName);
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index 4ad20e6c4..4bbe15b0c 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -49,8 +49,6 @@ int mapif_guild_info(int fd,struct guild *g);
int guild_break_sub(int key,void *data,va_list ap);
int inter_guild_tosql(struct guild *g,int flag);
-#define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-
static int guild_save(DBKey key, void *data, va_list ap) {
struct guild *g = (struct guild*) data;
int *last_id = va_arg(ap, int *);
diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c
index 2260ddf20..acee4f823 100644
--- a/src/char_sql/int_homun.c
+++ b/src/char_sql/int_homun.c
@@ -12,17 +12,6 @@
struct s_homunculus *homun_pt;
-#ifndef SQL_DEBUG
-
-#define mysql_query(_x, _y) mysql_real_query(_x, _y, strlen(_y)) //supports ' in names and runs faster [Kevin]
-
-#else
-
-#define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-
-#endif
-
-
int inter_homunculus_sql_init(void){
//memory alloc
homun_pt = (struct s_homunculus*)aCalloc(sizeof(struct s_homunculus), 1);
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index dbb431cfd..181050e4e 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -34,16 +34,6 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id);
int party_check_exp_share(struct party_data *p);
int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag);
-#ifndef SQL_DEBUG
-
-#define mysql_query(_x, _y) mysql_real_query(_x, _y, strlen(_y)) //supports ' in names and runs faster [Kevin]
-
-#else
-
-#define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-
-#endif
-
//Updates party's level range and unsets even share if broken.
static int int_party_check_lv(struct party_data *p) {
int i;
diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c
index 099b02aaa..3f6406be5 100644
--- a/src/char_sql/int_pet.c
+++ b/src/char_sql/int_pet.c
@@ -15,16 +15,6 @@
struct s_pet *pet_pt;
-#ifndef SQL_DEBUG
-
-#define mysql_query(_x, _y) mysql_real_query(_x, _y, strlen(_y)) //supports ' in names and runs faster [Kevin]
-
-#else
-
-#define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-
-#endif
-
//---------------------------------------------------------
int inter_pet_tosql(int pet_id, struct s_pet *p) {
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c
index 72b56e5ef..a52e5b530 100644
--- a/src/char_sql/int_storage.c
+++ b/src/char_sql/int_storage.c
@@ -20,16 +20,6 @@
struct storage *storage_pt=NULL;
struct guild_storage *guild_storage_pt=NULL;
-#ifndef SQL_DEBUG
-
-#define mysql_query(_x, _y) mysql_real_query(_x, _y, strlen(_y)) //supports ' in names and runs faster [Kevin]
-
-#else
-
-#define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-
-#endif
-
#endif //TXT_SQL_CONVERT
// storage data -> DB conversion
int storage_tosql(int account_id,struct storage *p){
diff --git a/src/common/core.h b/src/common/core.h
index 7784a95bb..68325505a 100644
--- a/src/common/core.h
+++ b/src/common/core.h
@@ -4,8 +4,6 @@
#ifndef _CORE_H_
#define _CORE_H_
-//#define SQL_DEBUG //uncomment for debug_mysql_query instead of mysql_real_query
-
extern int arg_c;
extern char **arg_v;
diff --git a/src/common/socket.h b/src/common/socket.h
index a7734963a..f1997defe 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -21,19 +21,10 @@
// socket I/O macros
-#ifdef TURBO
-#define RFIFOVAR(fd) rbPtr ## fd
-#define WFIFOVAR(fd) wbPtr ## fd
-#define RFIFOHEAD(fd) uint8 *RFIFOVAR(fd) = session[fd]->rdata+session[fd]->rdata_pos
-#define WFIFOHEAD(fd, x) uint8 *WFIFOVAR(fd) = ( (fd) > 0 && session[fd] ? session[fd]->wdata+session[fd]->wdata_size : NULL )
-#define RFIFOP(fd,pos) ( &RFIFOVAR(fd) + (pos) )
-#define WFIFOP(fd,pos) ( &WFIFOVAR(fd) + (pos) )
-#else
#define RFIFOHEAD(fd)
#define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo(fd, size); }while(0)
#define RFIFOP(fd,pos) (session[fd]->rdata + session[fd]->rdata_pos + (pos))
#define WFIFOP(fd,pos) (session[fd]->wdata + session[fd]->wdata_size + (pos))
-#endif
#define RFIFOB(fd,pos) (*(uint8*)RFIFOP(fd,pos))
#define WFIFOB(fd,pos) (*(uint8*)WFIFOP(fd,pos))
diff --git a/src/login/login.c b/src/login/login.c
index 059facfde..c507cc2cc 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -972,8 +972,6 @@ int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
for(i = 0, c = 0; i < MAX_SERVERS; i++) {
if ((fd = server_fd[i]) >= 0 && fd != sfd) {
WFIFOHEAD(fd,len);
- if (WFIFOSPACE(fd) < len) //Increase buffer size.
- realloc_writefifo(fd, len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
c++;
@@ -984,9 +982,9 @@ int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
}
//-----------------------------------------------------
-// Send GM accounts to all char-server
+// Send GM accounts to one or all char-servers
//-----------------------------------------------------
-void send_GM_accounts(void)
+void send_GM_accounts(int fd)
{
unsigned int i;
uint8 buf[32767];
@@ -1007,7 +1005,13 @@ void send_GM_accounts(void)
}
WBUFW(buf,2) = len;
- charif_sendallwos(-1, buf, len);
+ if (fd == -1) // send to all charservers
+ charif_sendallwos(-1, buf, len);
+ else { // send only to target
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
+ }
return;
}
@@ -1032,7 +1036,7 @@ int check_GM_file(int tid, unsigned int tick, int id, int data)
if (new_time != creation_time_GM_account_file) {
read_gm_account();
- send_GM_accounts();
+ send_GM_accounts(-1);
}
return 0;
@@ -1366,9 +1370,6 @@ int parse_fromchar(int fd)
int j, id;
uint32 ipl = session[fd]->client_addr;
char ip[16];
- RFIFOHEAD(fd);
-
- ip2str(ipl, ip);
for(id = 0; id < MAX_SERVERS; id++)
if (server_fd[id] == fd)
@@ -1379,6 +1380,8 @@ int parse_fromchar(int fd)
return 0;
}
+ ip2str(ipl, ip);
+
if(session[fd]->eof) {
ShowStatus("Char-server '%s' has disconnected.\n", server[id].name);
login_log("Char-server '%s' has disconnected (ip: %s)." RETCODE, server[id].name, ip);
@@ -1403,7 +1406,7 @@ int parse_fromchar(int fd)
login_log("Char-server '%s': Request to re-load GM configuration file (ip: %s)." RETCODE, server[id].name, ip);
read_gm_account();
// send GM accounts to all char-servers
- send_GM_accounts();
+ send_GM_accounts(-1);
RFIFOSKIP(fd,2);
break;
@@ -1424,7 +1427,6 @@ int parse_fromchar(int fd)
unsigned int k;
time_t connect_until_time = 0;
char email[40] = "";
- WFIFOHEAD(fd,51);
auth_fifo[i].delflag = 1;
login_log("Char-server '%s': authentification of the account %d accepted (ip: %s)." RETCODE,
server[id].name, account_id, ip);
@@ -1435,6 +1437,7 @@ int parse_fromchar(int fd)
break;
}
}
+ WFIFOHEAD(fd,51);
WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id;
WFIFOB(fd,6) = 0;
@@ -1456,9 +1459,10 @@ int parse_fromchar(int fd)
// It is unnecessary to send validity date of the account
WFIFOSET(fd,51);
}
- }
+
RFIFOSKIP(fd,19);
- break;
+ }
+ break;
case 0x2714:
if (RFIFOREST(fd) < 6)
@@ -1471,7 +1475,7 @@ int parse_fromchar(int fd)
WFIFOSET(fd,2);
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x2715: // request from char server to change e-email from default "a@a.com"
if (RFIFOREST(fd) < 46)
@@ -1496,9 +1500,10 @@ int parse_fromchar(int fd)
if (i == auth_num)
login_log("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s)." RETCODE, server[id].name, acc, ip);
}
- }
+
RFIFOSKIP(fd,46);
- break;
+ }
+ break;
case 0x2716: // received an e-mail/limited time request, because a player comes back from a map-server to the char-server
if (RFIFOREST(fd) < 6)
@@ -1519,63 +1524,65 @@ int parse_fromchar(int fd)
if (i == auth_num)
login_log("Char-server '%s': e-mail of the account %d NOT found (ip: %s)." RETCODE,
server[id].name, RFIFOL(fd,2), ip);
+
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x2720: // Request to become a GM
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
- {
- unsigned char buf[10];
- FILE *fp;
- int acc = RFIFOL(fd,4);
- //printf("parse_fromchar: Request to become a GM acount from %d account.\n", acc);
- WBUFW(buf,0) = 0x2721;
- WBUFL(buf,2) = acc;
- WBUFL(buf,6) = 0;
- if (strcmp((char*)RFIFOP(fd,8), gm_pass) == 0) {
- // only non-GM can become GM
- if (isGM(acc) == 0) {
- // if we autorise creation
- if (level_new_gm > 0) {
- // if we can open the file to add the new GM
- if ((fp = fopen(GM_account_filename, "a")) != NULL) {
- char tmpstr[24];
- time_t raw_time;
- time(&raw_time);
- strftime(tmpstr, 23, date_format, localtime(&raw_time));
- fprintf(fp, RETCODE "// %s: @GM command on account %d" RETCODE "%d %d" RETCODE, tmpstr, acc, acc, level_new_gm);
- fclose(fp);
- WBUFL(buf,6) = level_new_gm;
- read_gm_account();
- send_GM_accounts();
- ShowNotice("GM Change of the account %d: level 0 -> %d.\n", acc, level_new_gm);
- login_log("Char-server '%s': GM Change of the account %d: level 0 -> %d (ip: %s)." RETCODE,
- server[id].name, acc, level_new_gm, ip);
- } else {
- ShowError("Error of GM change (suggested account: %d, correct password, unable to add a GM account in GM accounts file)\n", acc);
- login_log("Char-server '%s': Error of GM change (suggested account: %d, correct password, unable to add a GM account in GM accounts file, ip: %s)." RETCODE,
- server[id].name, acc, ip);
- }
+ {
+ unsigned char buf[10];
+ FILE *fp;
+ int acc = RFIFOL(fd,4);
+ //printf("parse_fromchar: Request to become a GM acount from %d account.\n", acc);
+ WBUFW(buf,0) = 0x2721;
+ WBUFL(buf,2) = acc;
+ WBUFL(buf,6) = 0;
+ if (strcmp((char*)RFIFOP(fd,8), gm_pass) == 0) {
+ // only non-GM can become GM
+ if (isGM(acc) == 0) {
+ // if we autorise creation
+ if (level_new_gm > 0) {
+ // if we can open the file to add the new GM
+ if ((fp = fopen(GM_account_filename, "a")) != NULL) {
+ char tmpstr[24];
+ time_t raw_time;
+ time(&raw_time);
+ strftime(tmpstr, 23, date_format, localtime(&raw_time));
+ fprintf(fp, RETCODE "// %s: @GM command on account %d" RETCODE "%d %d" RETCODE, tmpstr, acc, acc, level_new_gm);
+ fclose(fp);
+ WBUFL(buf,6) = level_new_gm;
+ read_gm_account();
+ send_GM_accounts(-1);
+ ShowNotice("GM Change of the account %d: level 0 -> %d.\n", acc, level_new_gm);
+ login_log("Char-server '%s': GM Change of the account %d: level 0 -> %d (ip: %s)." RETCODE,
+ server[id].name, acc, level_new_gm, ip);
} else {
- ShowError("Error of GM change (suggested account: %d, correct password, but GM creation is disable (level_new_gm = 0))\n", acc);
- login_log("Char-server '%s': Error of GM change (suggested account: %d, correct password, but GM creation is disable (level_new_gm = 0), ip: %s)." RETCODE,
+ ShowError("Error of GM change (suggested account: %d, correct password, unable to add a GM account in GM accounts file)\n", acc);
+ login_log("Char-server '%s': Error of GM change (suggested account: %d, correct password, unable to add a GM account in GM accounts file, ip: %s)." RETCODE,
server[id].name, acc, ip);
}
} else {
- ShowError("Error of GM change (suggested account: %d (already GM), correct password).\n", acc);
- login_log("Char-server '%s': Error of GM change (suggested account: %d (already GM), correct password, ip: %s)." RETCODE,
+ ShowError("Error of GM change (suggested account: %d, correct password, but GM creation is disable (level_new_gm = 0))\n", acc);
+ login_log("Char-server '%s': Error of GM change (suggested account: %d, correct password, but GM creation is disable (level_new_gm = 0), ip: %s)." RETCODE,
server[id].name, acc, ip);
}
} else {
- ShowError("Error of GM change (suggested account: %d, invalid password).\n", acc);
- login_log("Char-server '%s': Error of GM change (suggested account: %d, invalid password, ip: %s)." RETCODE,
+ ShowError("Error of GM change (suggested account: %d (already GM), correct password).\n", acc);
+ login_log("Char-server '%s': Error of GM change (suggested account: %d (already GM), correct password, ip: %s)." RETCODE,
server[id].name, acc, ip);
}
- charif_sendallwos(-1, buf, 10);
- }
+ } else {
+ ShowError("Error of GM change (suggested account: %d, invalid password).\n", acc);
+ login_log("Char-server '%s': Error of GM change (suggested account: %d, invalid password, ip: %s)." RETCODE,
+ server[id].name, acc, ip);
+ }
+ charif_sendallwos(-1, buf, 10);
+
RFIFOSKIP(fd, RFIFOW(fd,2));
return 0;
+ }
// Map server send information to change an email of an account via char-server
case 0x2722: // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
@@ -1614,9 +1621,10 @@ int parse_fromchar(int fd)
login_log("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s)." RETCODE,
server[id].name, acc, ip);
}
- }
+
RFIFOSKIP(fd, 86);
- break;
+ }
+ break;
case 0x2724: // Receiving of map-server via char-server a status change resquest
if (RFIFOREST(fd) < 10)
@@ -1661,104 +1669,106 @@ int parse_fromchar(int fd)
if (RFIFOREST(fd) < 18)
return 0;
{
- uint32 acc = RFIFOL(fd,2);
- for(i = 0; i < auth_num; i++) {
- if (auth_dat[i].account_id == acc) {
- time_t timestamp;
- struct tm *tmtime;
- if (auth_dat[i].ban_until_time == 0 || auth_dat[i].ban_until_time < time(NULL))
- timestamp = time(NULL);
- else
- timestamp = auth_dat[i].ban_until_time;
- tmtime = localtime(&timestamp);
- tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,6);
- tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,8);
- tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,10);
- tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,12);
- tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,14);
- tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,16);
- timestamp = mktime(tmtime);
- if (timestamp != -1) {
- if (timestamp <= time(NULL))
- timestamp = 0;
- if (auth_dat[i].ban_until_time != timestamp) {
- if (timestamp != 0) {
- unsigned char buf[16];
- char tmpstr[2048];
- strftime(tmpstr, 24, date_format, localtime(&timestamp));
- login_log("Char-server '%s': Ban request (account: %d, new final date of banishment: %d (%s), ip: %s)." RETCODE,
- server[id].name, acc, timestamp, (timestamp == 0 ? "no banishment" : tmpstr), ip);
- WBUFW(buf,0) = 0x2731;
- WBUFL(buf,2) = auth_dat[i].account_id;
- WBUFB(buf,6) = 1; // 0: change of statut, 1: ban
- WBUFL(buf,7) = (unsigned int)timestamp; // status or final date of a banishment
- charif_sendallwos(-1, buf, 11);
- for(j = 0; j < AUTH_FIFO_SIZE; j++)
- if (auth_fifo[j].account_id == acc)
- auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification)
- } else {
- login_log("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s)." RETCODE,
- server[id].name, acc, ip);
- }
- auth_dat[i].ban_until_time = timestamp;
- // Save
- mmo_auth_sync();
+ uint32 acc = RFIFOL(fd,2);
+ for(i = 0; i < auth_num; i++) {
+ if (auth_dat[i].account_id == acc) {
+ time_t timestamp;
+ struct tm *tmtime;
+ if (auth_dat[i].ban_until_time == 0 || auth_dat[i].ban_until_time < time(NULL))
+ timestamp = time(NULL);
+ else
+ timestamp = auth_dat[i].ban_until_time;
+ tmtime = localtime(&timestamp);
+ tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,6);
+ tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,8);
+ tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,10);
+ tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,12);
+ tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,14);
+ tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,16);
+ timestamp = mktime(tmtime);
+ if (timestamp != -1) {
+ if (timestamp <= time(NULL))
+ timestamp = 0;
+ if (auth_dat[i].ban_until_time != timestamp) {
+ if (timestamp != 0) {
+ unsigned char buf[16];
+ char tmpstr[2048];
+ strftime(tmpstr, 24, date_format, localtime(&timestamp));
+ login_log("Char-server '%s': Ban request (account: %d, new final date of banishment: %d (%s), ip: %s)." RETCODE,
+ server[id].name, acc, timestamp, (timestamp == 0 ? "no banishment" : tmpstr), ip);
+ WBUFW(buf,0) = 0x2731;
+ WBUFL(buf,2) = auth_dat[i].account_id;
+ WBUFB(buf,6) = 1; // 0: change of statut, 1: ban
+ WBUFL(buf,7) = (unsigned int)timestamp; // status or final date of a banishment
+ charif_sendallwos(-1, buf, 11);
+ for(j = 0; j < AUTH_FIFO_SIZE; j++)
+ if (auth_fifo[j].account_id == acc)
+ auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification)
} else {
- login_log("Char-server '%s': Error of ban request (account: %d, no change for ban date, ip: %s)." RETCODE,
+ login_log("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s)." RETCODE,
server[id].name, acc, ip);
}
+ auth_dat[i].ban_until_time = timestamp;
+ // Save
+ mmo_auth_sync();
} else {
- login_log("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s)." RETCODE,
+ login_log("Char-server '%s': Error of ban request (account: %d, no change for ban date, ip: %s)." RETCODE,
server[id].name, acc, ip);
}
- break;
+ } else {
+ login_log("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s)." RETCODE,
+ server[id].name, acc, ip);
}
+ break;
}
- if (i == auth_num)
- login_log("Char-server '%s': Error of ban request (account: %d not found, ip: %s)." RETCODE,
- server[id].name, acc, ip);
- RFIFOSKIP(fd,18);
- return 0;
+ }
+ if (i == auth_num)
+ login_log("Char-server '%s': Error of ban request (account: %d not found, ip: %s)." RETCODE,
+ server[id].name, acc, ip);
+
+ RFIFOSKIP(fd,18);
+ return 0;
}
case 0x2727: // Change of sex (sex is reversed)
if (RFIFOREST(fd) < 6)
return 0;
{
- uint8 sex;
- uint32 acc = RFIFOL(fd,2);
- for(i = 0; i < auth_num; i++) {
- if (auth_dat[i].account_id == acc) {
- if (auth_dat[i].sex == 2)
- login_log("Char-server '%s': Error of sex change - Server account (suggested account: %d, actual sex %d (Server), ip: %s)." RETCODE,
- server[id].name, acc, auth_dat[i].sex, ip);
- else {
- unsigned char buf[16];
- if (auth_dat[i].sex == 0)
- sex = 1;
- else
- sex = 0;
- login_log("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s)." RETCODE,
- server[id].name, acc, (sex == 2) ? 'S' : (sex == 1 ? 'M' : 'F'), ip);
- for(j = 0; j < AUTH_FIFO_SIZE; j++)
- if (auth_fifo[j].account_id == acc)
- auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification)
- auth_dat[i].sex = sex;
- WBUFW(buf,0) = 0x2723;
- WBUFL(buf,2) = acc;
- WBUFB(buf,6) = sex;
- charif_sendallwos(-1, buf, 7);
- // Save
- mmo_auth_sync();
- }
- break;
+ uint8 sex;
+ uint32 acc = RFIFOL(fd,2);
+ for(i = 0; i < auth_num; i++) {
+ if (auth_dat[i].account_id == acc) {
+ if (auth_dat[i].sex == 2)
+ login_log("Char-server '%s': Error of sex change - Server account (suggested account: %d, actual sex %d (Server), ip: %s)." RETCODE,
+ server[id].name, acc, auth_dat[i].sex, ip);
+ else {
+ unsigned char buf[16];
+ if (auth_dat[i].sex == 0)
+ sex = 1;
+ else
+ sex = 0;
+ login_log("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s)." RETCODE,
+ server[id].name, acc, (sex == 2) ? 'S' : (sex == 1 ? 'M' : 'F'), ip);
+ for(j = 0; j < AUTH_FIFO_SIZE; j++)
+ if (auth_fifo[j].account_id == acc)
+ auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification)
+ auth_dat[i].sex = sex;
+ WBUFW(buf,0) = 0x2723;
+ WBUFL(buf,2) = acc;
+ WBUFB(buf,6) = sex;
+ charif_sendallwos(-1, buf, 7);
+ // Save
+ mmo_auth_sync();
}
+ break;
}
- if (i == auth_num)
- login_log("Char-server '%s': Error of sex change (account: %d not found, sex would be reversed, ip: %s)." RETCODE,
- server[id].name, acc, ip);
- RFIFOSKIP(fd,6);
- return 0;
+ }
+ if (i == auth_num)
+ login_log("Char-server '%s': Error of sex change (account: %d not found, sex would be reversed, ip: %s)." RETCODE,
+ server[id].name, acc, ip);
+
+ RFIFOSKIP(fd,6);
+ return 0;
}
case 0x2728: // We receive account_reg2 from a char-server, and we send them to other map-servers.
@@ -1803,47 +1813,49 @@ int parse_fromchar(int fd)
server[id].name, acc, ip);
}
}
+
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+ break;
case 0x272a: // Receiving of map-server via char-server a unban resquest
if (RFIFOREST(fd) < 6)
return 0;
- {
- uint32 acc = RFIFOL(fd,2);
- for(i = 0; i < auth_num; i++) {
- if (auth_dat[i].account_id == acc) {
- if (auth_dat[i].ban_until_time != 0) {
- auth_dat[i].ban_until_time = 0;
- login_log("Char-server '%s': UnBan request (account: %d, ip: %s)." RETCODE,
- server[id].name, acc, ip);
- } else {
- login_log("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s)." RETCODE,
- server[id].name, acc, ip);
- }
- break;
+ {
+ uint32 acc = RFIFOL(fd,2);
+ for(i = 0; i < auth_num; i++) {
+ if (auth_dat[i].account_id == acc) {
+ if (auth_dat[i].ban_until_time != 0) {
+ auth_dat[i].ban_until_time = 0;
+ login_log("Char-server '%s': UnBan request (account: %d, ip: %s)." RETCODE,
+ server[id].name, acc, ip);
+ } else {
+ login_log("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s)." RETCODE,
+ server[id].name, acc, ip);
}
+ break;
}
- if (i == auth_num)
- login_log("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s)." RETCODE,
- server[id].name, acc, ip);
- RFIFOSKIP(fd,6);
}
+ if (i == auth_num)
+ login_log("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s)." RETCODE,
+ server[id].name, acc, ip);
+
+ RFIFOSKIP(fd,6);
return 0;
+ }
case 0x272b: // Set account_id to online [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
add_online_user(id, RFIFOL(fd,2));
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x272c: // Set account_id to offline [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
remove_online_user(RFIFOL(fd,2));
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x272d: // Receive list of all online accounts. [Skotlex]
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -1866,36 +1878,38 @@ int parse_fromchar(int fd)
}
}
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+ break;
+
case 0x272e: //Request account_reg2 for a character.
if (RFIFOREST(fd) < 10)
return 0;
- {
- uint32 account_id = RFIFOL(fd, 2);
- uint32 char_id = RFIFOL(fd, 6);
- int p;
- RFIFOSKIP(fd,10);
- WFIFOW(fd,0) = 0x2729;
- WFIFOL(fd,4) = account_id;
- WFIFOL(fd,8) = char_id;
- WFIFOB(fd,12) = 1; //Type 1 for Account2 registry
- for(i = 0; i < auth_num && auth_dat[i].account_id != account_id; i++);
- if (i == auth_num) {
- //Account not found? Send at least empty data, map servers need a reply!
- WFIFOW(fd,2) = 13;
- WFIFOSET(fd,WFIFOW(fd,2));
- break;
- }
- for(p = 13, j = 0; j < auth_dat[i].account_reg2_num; j++) {
- if (auth_dat[i].account_reg2[j].str[0]) {
- p+= sprintf((char*)WFIFOP(fd,p), "%s", auth_dat[i].account_reg2[j].str)+1; //We add 1 to consider the '\0' in place.
- p+= sprintf((char*)WFIFOP(fd,p), "%s", auth_dat[i].account_reg2[j].value)+1;
- }
- }
- WFIFOW(fd,2) = (uint16) p;
+ {
+ uint32 account_id = RFIFOL(fd, 2);
+ uint32 char_id = RFIFOL(fd, 6);
+ int p;
+ WFIFOW(fd,0) = 0x2729;
+ WFIFOL(fd,4) = account_id;
+ WFIFOL(fd,8) = char_id;
+ WFIFOB(fd,12) = 1; //Type 1 for Account2 registry
+ for(i = 0; i < auth_num && auth_dat[i].account_id != account_id; i++);
+ if (i == auth_num) {
+ //Account not found? Send at least empty data, map servers need a reply!
+ WFIFOW(fd,2) = 13;
WFIFOSET(fd,WFIFOW(fd,2));
+ break;
}
- break;
+ for(p = 13, j = 0; j < auth_dat[i].account_reg2_num; j++) {
+ if (auth_dat[i].account_reg2[j].str[0]) {
+ p+= sprintf((char*)WFIFOP(fd,p), "%s", auth_dat[i].account_reg2[j].str)+1; //We add 1 to consider the '\0' in place.
+ p+= sprintf((char*)WFIFOP(fd,p), "%s", auth_dat[i].account_reg2[j].value)+1;
+ }
+ }
+ WFIFOW(fd,2) = (uint16) p;
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ RFIFOSKIP(fd,10);
+ }
+ break;
case 0x2736: // WAN IP update from char-server
if (RFIFOREST(fd) < 6)
@@ -1903,60 +1917,62 @@ int parse_fromchar(int fd)
server[id].ip = ntohl(RFIFOL(fd,2));
ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",id, CONVIP(server[id].ip));
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x2737: //Request to set all offline.
ShowInfo("Setting accounts from char-server %d offline.\n", id);
online_db->foreach(online_db,online_db_setoffline,id);
RFIFOSKIP(fd,2);
- break;
+ break;
default:
- {
- FILE *logfp;
- char tmpstr[24];
- time_t raw_time;
- logfp = fopen(login_log_unknown_packets_filename, "a");
- if (logfp) {
- time(&raw_time);
- strftime(tmpstr, 23, date_format, localtime(&raw_time));
- fprintf(logfp, "%s: receiving of an unknown packet -> disconnection" RETCODE, tmpstr);
- fprintf(logfp, "parse_fromchar: connection #%d (ip: %s), packet: 0x%x (with being read: %lu)." RETCODE, fd, ip, command, (unsigned long)RFIFOREST(fd));
- fprintf(logfp, "Detail (in hex):" RETCODE);
- fprintf(logfp, "---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F" RETCODE);
- memset(tmpstr, '\0', sizeof(tmpstr));
- for(i = 0; i < RFIFOREST(fd); i++) {
- if ((i & 15) == 0)
- fprintf(logfp, "%04X ",i);
- fprintf(logfp, "%02x ", RFIFOB(fd,i));
- if (RFIFOB(fd,i) > 0x1f)
- tmpstr[i % 16] = RFIFOB(fd,i);
- else
- tmpstr[i % 16] = '.';
- if ((i - 7) % 16 == 0) // -8 + 1
- fprintf(logfp, " ");
- else if ((i + 1) % 16 == 0) {
- fprintf(logfp, " %s" RETCODE, tmpstr);
- memset(tmpstr, '\0', sizeof(tmpstr));
- }
- }
- if (i % 16 != 0) {
- for(j = i; j % 16 != 0; j++) {
- fprintf(logfp, " ");
- if ((j - 7) % 16 == 0) // -8 + 1
- fprintf(logfp, " ");
- }
+ {
+ FILE* logfp;
+ char tmpstr[24];
+ time_t raw_time;
+ logfp = fopen(login_log_unknown_packets_filename, "a");
+ if (logfp) {
+ time(&raw_time);
+ strftime(tmpstr, 23, date_format, localtime(&raw_time));
+ fprintf(logfp, "%s: receiving of an unknown packet -> disconnection" RETCODE, tmpstr);
+ fprintf(logfp, "parse_fromchar: connection #%d (ip: %s), packet: 0x%x (with being read: %lu)." RETCODE, fd, ip, command, (unsigned long)RFIFOREST(fd));
+ fprintf(logfp, "Detail (in hex):" RETCODE);
+ fprintf(logfp, "---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F" RETCODE);
+ memset(tmpstr, '\0', sizeof(tmpstr));
+ for(i = 0; i < RFIFOREST(fd); i++) {
+ if ((i & 15) == 0)
+ fprintf(logfp, "%04X ",i);
+ fprintf(logfp, "%02x ", RFIFOB(fd,i));
+ if (RFIFOB(fd,i) > 0x1f)
+ tmpstr[i % 16] = RFIFOB(fd,i);
+ else
+ tmpstr[i % 16] = '.';
+ if ((i - 7) % 16 == 0) // -8 + 1
+ fprintf(logfp, " ");
+ else if ((i + 1) % 16 == 0) {
fprintf(logfp, " %s" RETCODE, tmpstr);
+ memset(tmpstr, '\0', sizeof(tmpstr));
}
- fprintf(logfp, RETCODE);
- fclose(logfp);
}
+ if (i % 16 != 0) {
+ for(j = i; j % 16 != 0; j++) {
+ fprintf(logfp, " ");
+ if ((j - 7) % 16 == 0) // -8 + 1
+ fprintf(logfp, " ");
+ }
+ fprintf(logfp, " %s" RETCODE, tmpstr);
+ }
+ fprintf(logfp, RETCODE);
+ fclose(logfp);
}
+
ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command);
set_eof(fd);
return 0;
}
- }
+ } // switch
+ } // while
+
RFIFOSKIP(fd,RFIFOREST(fd));
return 0;
}
@@ -1970,7 +1986,6 @@ int parse_admin(int fd)
uint32 ipl = session[fd]->client_addr;
char* account_name;
char ip[16];
- RFIFOHEAD(fd);
ip2str(ipl, ip);
@@ -2411,7 +2426,7 @@ int parse_admin(int fd)
auth_dat[i].userid, acc, (int)new_gm_level, ip);
// read and send new GM informations
read_gm_account();
- send_GM_accounts();
+ send_GM_accounts(-1);
} else {
login_log("'ladmin': Attempt to modify of a GM level - impossible to write GM accounts file (account: %s (%d), received GM level: %d, ip: %s)" RETCODE,
auth_dat[i].userid, acc, (int)new_gm_level, ip);
@@ -2876,7 +2891,7 @@ int parse_admin(int fd)
login_log("'ladmin': Request to re-load GM configuration file (ip: %s)." RETCODE, ip);
read_gm_account();
// send GM accounts to all char-servers
- send_GM_accounts();
+ send_GM_accounts(-1);
RFIFOSKIP(fd,2);
break;
@@ -2926,8 +2941,6 @@ int parse_admin(int fd)
ShowWarning("Remote administration has been disconnected (unknown packet).\n");
return 0;
}
- //WFIFOW(fd,0) = 0x791f;
- //WFIFOSET(fd,2);
}
RFIFOSKIP(fd,RFIFOREST(fd));
return 0;
@@ -2959,17 +2972,14 @@ int parse_login(int fd)
unsigned int i;
uint32 ipl = session[fd]->client_addr;
char ip[16];
- RFIFOHEAD(fd);
-
- ip2str(ipl, ip);
-
- memset(&account, 0, sizeof(account));
if (session[fd]->eof) {
do_close(fd);
return 0;
}
+ ip2str(ipl, ip);
+
while (RFIFOREST(fd) >= 2)
{
uint16 command = RFIFOW(fd,0);
@@ -2996,19 +3006,19 @@ int parse_login(int fd)
if (RFIFOREST(fd) < 26)
return 0;
RFIFOSKIP(fd,26);
- break;
+ break;
case 0x0204: // New alive packet: structure: 0x204 <encrypted.account.userid>.16B. (new ragexe from 22 june 2004)
if (RFIFOREST(fd) < 18)
return 0;
RFIFOSKIP(fd,18);
- break;
+ break;
case 0x0064: // request client login
case 0x0277: // New login packet (layout is same as 0x64 but different length)
case 0x01dd: // request client login (encryption mode)
{
- int packet_len = RFIFOREST(fd);
+ int packet_len = RFIFOREST(fd); // assume no other packet was sent
//Perform ip-ban check
if (!check_ip(ipl))
@@ -3032,6 +3042,7 @@ int parse_login(int fd)
// S 0277 ??
// S 01dd <version>.l <account name>.24B <md5 binary>.16B <version2>.B
+ memset(&account, 0, sizeof(account));
account.version = RFIFOL(fd,2);
if (!account.version) account.version = 1; //Force some version...
memcpy(account.userid,RFIFOP(fd,6),NAME_LENGTH); account.userid[23] = '\0';
@@ -3120,9 +3131,10 @@ int parse_login(int fd)
}
WFIFOSET(fd,23);
}
+
RFIFOSKIP(fd,packet_len);
- break;
}
+ break;
case 0x01db: // Sending request of the coding key
case 0x791a: // Sending request of the coding key (administration packet)
@@ -3147,12 +3159,13 @@ int parse_login(int fd)
for(i = 0; i < ld->md5keylen; i++)
ld->md5key[i] = (char)(1 + rand() % 255);
- RFIFOSKIP(fd,2);
WFIFOHEAD(fd,4 + ld->md5keylen);
WFIFOW(fd,0) = 0x01dc;
WFIFOW(fd,2) = 4 + ld->md5keylen;
memcpy(WFIFOP(fd,4), ld->md5key, ld->md5keylen);
WFIFOSET(fd,WFIFOW(fd,2));
+
+ RFIFOSKIP(fd,2);
}
break;
@@ -3160,12 +3173,11 @@ int parse_login(int fd)
if (RFIFOREST(fd) < 86)
return 0;
{
- uint16 len;
char* server_name;
uint32 server_ip;
uint16 server_port;
- WFIFOHEAD(fd,3);
+ memset(&account, 0, sizeof(account));
memcpy(account.userid, RFIFOP(fd,2), NAME_LENGTH); account.userid[23] = '\0'; remove_control_chars(account.userid);
memcpy(account.passwd, RFIFOP(fd,26), NAME_LENGTH); account.passwd[23] = '\0'; remove_control_chars(account.passwd);
account.passwdenc = 0;
@@ -3188,29 +3200,16 @@ int parse_login(int fd)
server[account.account_id].maintenance = RFIFOW(fd,82);
server[account.account_id].new_ = RFIFOW(fd,84);
server_fd[account.account_id] = fd;
+
+ WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x2711;
WFIFOB(fd,2) = 0;
WFIFOSET(fd,3);
+
session[fd]->func_parse = parse_fromchar;
realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
-
- //TODO: why not use send_GM_accounts(fd)?
- // send GM account to char-server
- len = 4;
- WFIFOW(fd,0) = 0x2732;
- for(i = 0; i < auth_num; i++) {
- // send only existing accounts. We can not create a GM account when server is online.
- int GM_value;
- if ((GM_value = isGM(auth_dat[i].account_id)) > 0) {
- WFIFOL(fd,len) = auth_dat[i].account_id;
- WFIFOB(fd,len+4) = (unsigned char)GM_value;
- len += 5;
- }
- }
- WFIFOW(fd,2) = len;
- WFIFOSET(fd,len);
- // /TODO
-
+
+ send_GM_accounts(fd); // send GM account to char-server
} else {
if (server_fd[account.account_id] != -1) {
ShowNotice("Connection of the char-server '%s' REFUSED - already connected (account: %ld-%s, pass: %s, ip: %s)\n",
@@ -3228,11 +3227,11 @@ int parse_login(int fd)
WFIFOSET(fd,3);
}
}
+
RFIFOSKIP(fd,86);
return 0;
case 0x7530: // Server version information request
- {
login_log("Sending of the server version (ip: %s)" RETCODE, ip);
WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x7531;
@@ -3244,9 +3243,9 @@ int parse_login(int fd)
WFIFOB(fd,7) = ATHENA_SERVER_LOGIN;
WFIFOW(fd,8) = ATHENA_MOD_VERSION;
WFIFOSET(fd,10);
+
RFIFOSKIP(fd,2);
- break;
- }
+ break;
case 0x7532: // Request to end connection
login_log("End of connection (ip: %s)" RETCODE, ip);
@@ -3302,8 +3301,9 @@ int parse_login(int fd)
}
}
WFIFOSET(fd,3);
+
RFIFOSKIP(fd, (RFIFOW(fd,2) == 0) ? 28 : 20);
- break;
+ break;
default:
if (save_unknown_packets) {
@@ -3351,6 +3351,7 @@ int parse_login(int fd)
return 0;
}
}
+
RFIFOSKIP(fd,RFIFOREST(fd));
return 0;
}
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index bad4c8731..a24a9ed80 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -225,13 +225,13 @@ void read_gm_account(void)
}
//-----------------------------------------------------
-// Send GM accounts to all char-server
+// Send GM accounts to one or all char-servers
//-----------------------------------------------------
void send_GM_accounts(int fd)
{
unsigned int i;
- unsigned char buf[32767];
- int len;
+ uint8 buf[32767];
+ uint16 len;
if(!login_config.login_gm_read)
return;
@@ -242,7 +242,7 @@ void send_GM_accounts(int fd)
// send only existing accounts. We can not create a GM account when server is online.
if (gm_account_db[i].level > 0) {
WBUFL(buf,len) = gm_account_db[i].account_id;
- WBUFB(buf,len+4) = (unsigned char)gm_account_db[i].level;
+ WBUFB(buf,len+4) = (uint8)gm_account_db[i].level;
len += 5;
if (len >= 32000) {
ShowWarning("send_GM_accounts: Too many accounts! Only %d out of %d were sent.\n", i, GM_num);
@@ -251,14 +251,14 @@ void send_GM_accounts(int fd)
}
WBUFW(buf,2) = len;
- if (fd == -1)
+ if (fd == -1) // send to all charservers
charif_sendallwos(-1, buf, len);
- else
- {
+ else { // send only to target
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
}
+
return;
}
@@ -455,6 +455,7 @@ int mmo_auth_new(struct mmo_account* account, char sex)
return 0;
}
+
//--------------------------------------------------------------------
// Packet send to all char-servers, except one (wos: without our self)
//--------------------------------------------------------------------
@@ -465,8 +466,6 @@ int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
for(i = 0, c = 0; i < MAX_SERVERS; i++) {
if ((fd = server_fd[i]) > 0 && fd != sfd) {
WFIFOHEAD(fd,len);
- if (WFIFOSPACE(fd) < len) //Increase buffer size.
- realloc_writefifo(fd, len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
c++;
@@ -727,9 +726,6 @@ int parse_fromchar(int fd)
uint32 ipl = session[fd]->client_addr;
char ip[16];
- RFIFOHEAD(fd);
-
- ip2str(ipl, ip);
for(id = 0; id < MAX_SERVERS; id++)
if (server_fd[id] == fd)
@@ -740,6 +736,8 @@ int parse_fromchar(int fd)
return 0;
}
+ ip2str(ipl, ip);
+
if(session[fd]->eof) {
ShowStatus("Char-server '%s' has disconnected.\n", server[id].name);
server_fd[id] = -1;
@@ -774,14 +772,13 @@ int parse_fromchar(int fd)
// send GM accounts to all char-servers
send_GM_accounts(-1);
RFIFOSKIP(fd,2);
- break;
+ break;
case 0x2712: // request from char-server to authenticate an account
if (RFIFOREST(fd) < 19)
return 0;
{
int account_id;
- WFIFOHEAD(fd,51);
account_id = RFIFOL(fd,2); // speed up
for(i = 0; i < AUTH_FIFO_SIZE; i++) {
if( auth_fifo[i].account_id == account_id &&
@@ -812,6 +809,7 @@ int parse_fromchar(int fd)
strncpy(email, sql_row[0], 40); email[39] = 0;
mysql_free_result(sql_res);
}
+ WFIFOHEAD(fd,51);
WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id;
WFIFOB(fd,6) = 0;
@@ -819,19 +817,21 @@ int parse_fromchar(int fd)
WFIFOL(fd,47) = (unsigned long) connect_until_time;
WFIFOSET(fd,51);
} else {
+ WFIFOHEAD(fd,51);
WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id;
WFIFOB(fd,6) = 1;
WFIFOSET(fd,51);
}
- }
+
RFIFOSKIP(fd,19);
- break;
-
+ }
+ break;
case 0x2714:
if (RFIFOREST(fd) < 6)
return 0;
+
// how many users on world? (update)
if (server[id].users != RFIFOL(fd,2))
{
@@ -845,13 +845,13 @@ int parse_fromchar(int fd)
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
}
}
- { // send some answer
+ // send some answer
WFIFOHEAD(fd,6);
WFIFOW(fd,0) = 0x2718;
WFIFOSET(fd,2);
- }
+
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x2716: // received an e-mail/limited time request, because a player comes back from a map-server to the char-server
if (RFIFOREST(fd) < 6)
@@ -860,8 +860,7 @@ int parse_fromchar(int fd)
int account_id;
time_t connect_until_time = 0;
char email[40] = "";
- WFIFOHEAD(fd,50);
- account_id=RFIFOL(fd,2);
+ account_id = RFIFOL(fd,2);
sprintf(tmpsql,"SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'",login_db, login_db_account_id, account_id);
if(mysql_query(&mysql_handle, tmpsql)) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
@@ -875,14 +874,16 @@ int parse_fromchar(int fd)
}
mysql_free_result(sql_res);
//printf("parse_fromchar: E-mail/limited time request from '%s' server (concerned account: %d)\n", server[id].name, RFIFOL(fd,2));
+ WFIFOHEAD(fd,50);
WFIFOW(fd,0) = 0x2717;
WFIFOL(fd,2) = RFIFOL(fd,2);
memcpy(WFIFOP(fd, 6), email, 40);
WFIFOL(fd,46) = (unsigned long) connect_until_time;
WFIFOSET(fd,50);
- }
+
RFIFOSKIP(fd,6);
- break;
+ }
+ break;
case 0x2720: // Request to become a GM (TXT only!)
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -891,14 +892,13 @@ int parse_fromchar(int fd)
ShowWarning("change GM isn't supported in this login server version.\n");
ShowError("change GM error 0 %s\n", RFIFOP(fd, 8));
- RFIFOSKIP(fd, RFIFOW(fd, 2));
- {
WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x2721;
WFIFOL(fd,2) = RFIFOL(fd,4); // oldacc;
WFIFOL(fd,6) = 0; // newacc;
WFIFOSET(fd,10);
- }
+
+ RFIFOSKIP(fd, RFIFOW(fd, 2));
return 0;
// Map server send information to change an email of an account via char-server
@@ -944,9 +944,10 @@ int parse_fromchar(int fd)
}
}
+
RFIFOSKIP(fd, 86);
- break;
}
+ break;
case 0x2724: // Receiving of map-server via char-server a status change resquest
if (RFIFOREST(fd) < 10)
@@ -978,9 +979,10 @@ int parse_fromchar(int fd)
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
}
+
RFIFOSKIP(fd,10);
- break;
}
+ break;
case 0x2725: // Receiving of map-server via char-server a ban resquest
if (RFIFOREST(fd) < 18)
@@ -1033,9 +1035,10 @@ int parse_fromchar(int fd)
}
}
}
+
RFIFOSKIP(fd,18);
- break;
}
+ break;
case 0x2727: // Change of sex (sex is reversed)
if (RFIFOREST(fd) < 6)
@@ -1043,7 +1046,7 @@ int parse_fromchar(int fd)
{
int acc,sex;
unsigned char buf[16];
- acc=RFIFOL(fd,2);
+ acc = RFIFOL(fd,2);
sprintf(tmpsql,"SELECT `sex` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc);
if(mysql_query(&mysql_handle, tmpsql)) {
@@ -1076,9 +1079,10 @@ int parse_fromchar(int fd)
WBUFL(buf,2) = acc;
WBUFB(buf,6) = sex;
charif_sendallwos(-1, buf, 7);
+
RFIFOSKIP(fd,6);
- break;
}
+ break;
case 0x2728: // save account_reg2
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -1090,7 +1094,7 @@ int parse_fromchar(int fd)
char temp_str2[512];
char value[256];
unsigned char *buf;
- acc=RFIFOL(fd,4);
+ acc = RFIFOL(fd,4);
buf = (unsigned char*)aCalloc(RFIFOW(fd,2)+1, sizeof(unsigned char));
//Delete all global account variables....
sprintf(tmpsql,"DELETE FROM `%s` WHERE `type`='1' AND `account_id`='%d';",reg_db,acc);
@@ -1121,46 +1125,47 @@ int parse_fromchar(int fd)
if (buf) aFree(buf);
}
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+ break;
case 0x272a: // Receiving of map-server via char-server a unban resquest
if (RFIFOREST(fd) < 6)
return 0;
- {
- int acc;
- acc = RFIFOL(fd,2);
- sprintf(tmpsql,"SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc);
+ {
+ int acc;
+ acc = RFIFOL(fd,2);
+ sprintf(tmpsql,"SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc);
+ if(mysql_query(&mysql_handle, tmpsql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
+ }
+ sql_res = mysql_store_result(&mysql_handle) ;
+ if (sql_res && mysql_num_rows(sql_res) > 0) { //Found a match
+ sprintf(tmpsql,"UPDATE `%s` SET `ban_until` = '0' WHERE `%s` = '%d'", login_db,login_db_account_id,acc);
+ //query
if(mysql_query(&mysql_handle, tmpsql)) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
}
- sql_res = mysql_store_result(&mysql_handle) ;
- if (sql_res && mysql_num_rows(sql_res) > 0) { //Found a match
- sprintf(tmpsql,"UPDATE `%s` SET `ban_until` = '0' WHERE `%s` = '%d'", login_db,login_db_account_id,acc);
- //query
- if(mysql_query(&mysql_handle, tmpsql)) {
- ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
- }
- }
- if (sql_res) mysql_free_result(sql_res);
- RFIFOSKIP(fd,6);
}
+ if (sql_res) mysql_free_result(sql_res);
+
+ RFIFOSKIP(fd,6);
return 0;
+ }
case 0x272b: // Set account_id to online [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
add_online_user(id, RFIFOL(fd,2));
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x272c: // Set account_id to offline [Wizputer]
if (RFIFOREST(fd) < 6)
return 0;
remove_online_user(RFIFOL(fd,2));
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x272d: // Receive list of all online accounts. [Skotlex]
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
@@ -1182,43 +1187,46 @@ int parse_fromchar(int fd)
}
}
RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
+
+ break;
case 0x272e: //Request account_reg2 for a character.
if (RFIFOREST(fd) < 10)
return 0;
- {
- int account_id = RFIFOL(fd, 2);
- int char_id = RFIFOL(fd, 6);
- int p;
- WFIFOHEAD(fd,10000);
- RFIFOSKIP(fd,10);
- sprintf(tmpsql, "SELECT `str`,`value` FROM `%s` WHERE `type`='1' AND `account_id`='%d'",reg_db, account_id);
- if (mysql_query(&mysql_handle, tmpsql)) {
- ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
- break;
- }
- sql_res = mysql_store_result(&mysql_handle) ;
- if (!sql_res) {
- break;
- }
- WFIFOW(fd,0) = 0x2729;
- WFIFOL(fd,4) = account_id;
- WFIFOL(fd,8) = char_id;
- WFIFOB(fd,12) = 1; //Type 1 for Account2 registry
- for(p = 13; (sql_row = mysql_fetch_row(sql_res)) && p < 9000;){
- if (sql_row[0][0]) {
- p+= sprintf(WFIFOP(fd,p), "%s", sql_row[0])+1; //We add 1 to consider the '\0' in place.
- p+= sprintf(WFIFOP(fd,p), "%s", sql_row[1])+1;
- }
+ {
+ int account_id = RFIFOL(fd, 2);
+ int char_id = RFIFOL(fd, 6);
+ int p;
+ sprintf(tmpsql, "SELECT `str`,`value` FROM `%s` WHERE `type`='1' AND `account_id`='%d'",reg_db, account_id);
+ if (mysql_query(&mysql_handle, tmpsql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
+ break;
+ }
+ sql_res = mysql_store_result(&mysql_handle) ;
+ if (!sql_res) {
+ break;
+ }
+ WFIFOHEAD(fd,10000);
+ WFIFOW(fd,0) = 0x2729;
+ WFIFOL(fd,4) = account_id;
+ WFIFOL(fd,8) = char_id;
+ WFIFOB(fd,12) = 1; //Type 1 for Account2 registry
+ p = 13;
+ while ((sql_row = mysql_fetch_row(sql_res)) && p < 9000) {
+ if (sql_row[0][0]) {
+ p+= sprintf(WFIFOP(fd,p), "%s", sql_row[0])+1; //We add 1 to consider the '\0' in place.
+ p+= sprintf(WFIFOP(fd,p), "%s", sql_row[1])+1;
}
- if (p >= 9000)
- ShowWarning("Too many account2 registries for AID %d. Some registries were not sent.\n", account_id);
- WFIFOW(fd,2) = p;
- WFIFOSET(fd,WFIFOW(fd,2));
- mysql_free_result(sql_res);
}
- break;
+ mysql_free_result(sql_res);
+ if (p >= 9000)
+ ShowWarning("Too many account2 registries for AID %d. Some registries were not sent.\n", account_id);
+ WFIFOW(fd,2) = p;
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ RFIFOSKIP(fd,10);
+ }
+ break;
case 0x2736: // WAN IP update from char-server
if (RFIFOREST(fd) < 6)
@@ -1226,20 +1234,20 @@ int parse_fromchar(int fd)
server[id].ip = ntohl(RFIFOL(fd,2));
ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",id, CONVIP(server[id].ip));
RFIFOSKIP(fd,6);
- break;
+ break;
case 0x2737: //Request to set all offline.
ShowInfo("Setting accounts from char-server %d offline.\n", id);
online_db->foreach(online_db,online_db_setoffline,id);
RFIFOSKIP(fd,2);
- break;
+ break;
default:
ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", RFIFOW(fd,0));
set_eof(fd);
return 0;
- }
- }
+ } // switch
+ } // while
RFIFOSKIP(fd,RFIFOREST(fd));
return 0;
@@ -1311,12 +1319,9 @@ int parse_login(int fd)
int result, i;
uint32 ipl = session[fd]->client_addr;
char ip[16];
- RFIFOHEAD(fd);
ip2str(ipl, ip);
- memset(&account, 0, sizeof(account));
-
if (session[fd]->eof) {
do_close(fd);
return 0;
@@ -1332,13 +1337,13 @@ int parse_login(int fd)
if (RFIFOREST(fd) < 26)
return 0;
RFIFOSKIP(fd,26);
- break;
+ break;
case 0x0204: // New alive packet: structure: 0x204 <encrypted.account.userid>.16B. (new ragexe from 22 june 2004)
if (RFIFOREST(fd) < 18)
return 0;
RFIFOSKIP(fd,18);
- break;
+ break;
case 0x0064: // request client login
case 0x0277: // New login packet (layout is same as 0x64 but different length)
@@ -1367,6 +1372,7 @@ int parse_login(int fd)
// S 0277 ??
// S 01dd <version>.l <account name>.24B <md5 binary>.16B <version2>.B
+ memset(&account, 0, sizeof(account));
account.version = RFIFOL(fd,2);
if (!account.version) account.version = 1; //Force some version...
memcpy(account.userid,RFIFOP(fd,6),NAME_LENGTH); account.userid[23] = '\0';
@@ -1382,7 +1388,6 @@ int parse_login(int fd)
WFIFOB(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
} else {
- WFIFOHEAD(fd,47+32*MAX_SERVERS);
if (login_config.log_login) {
sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s','100', 'login ok')", loginlog_db, ipl, t_uid);
//query
@@ -1397,6 +1402,7 @@ int parse_login(int fd)
ShowStatus("Connection of the account '%s' accepted.\n", account.userid);
server_num = 0;
+ WFIFOHEAD(fd,47+32*MAX_SERVERS);
for(i = 0; i < MAX_SERVERS; i++) {
if (server_fd[i] >= 0) {
// Advanced subnet check [LuzZza]
@@ -1436,7 +1442,6 @@ int parse_login(int fd)
}
}
} else { // auth failed
- WFIFOHEAD(fd,23);
if (login_config.log_login)
{
const char* error;
@@ -1519,6 +1524,7 @@ int parse_login(int fd)
sql_row = sql_res?mysql_fetch_row(sql_res):NULL;
//cannot connect login failed
+ WFIFOHEAD(fd,23);
memset(WFIFOP(fd,0), '\0', 23);
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = (uint8)result;
@@ -1532,9 +1538,10 @@ int parse_login(int fd)
if (sql_res) mysql_free_result(sql_res);
}
+
RFIFOSKIP(fd,packet_len);
- break;
}
+ break;
case 0x01db: // Sending request of the coding key
{
@@ -1554,87 +1561,91 @@ int parse_login(int fd)
for(i = 0; i < ld->md5keylen; i++)
ld->md5key[i] = (char)(1 + rand() % 255);
- RFIFOSKIP(fd,2);
WFIFOHEAD(fd,4 + ld->md5keylen);
WFIFOW(fd,0) = 0x01dc;
WFIFOW(fd,2) = 4 + ld->md5keylen;
memcpy(WFIFOP(fd,4), ld->md5key, ld->md5keylen);
WFIFOSET(fd,WFIFOW(fd,2));
+
+ RFIFOSKIP(fd,2);
}
break;
case 0x2710: // Connection request of a char-server
if (RFIFOREST(fd) < 86)
return 0;
+ {
+ char* server_name;
+ uint32 server_ip;
+ uint16 server_port;
+
+ memset(&account, 0, sizeof(account));
+ memcpy(account.userid,RFIFOP(fd,2),NAME_LENGTH); account.userid[23] = '\0';
+ memcpy(account.passwd,RFIFOP(fd,26),NAME_LENGTH); account.passwd[23] = '\0';
+ account.passwdenc = 0;
+ server_name = (char*)RFIFOP(fd,60); server_name[20] = '\0';
+ server_ip = ntohl(RFIFOL(fd,54));
+ server_port = ntohs(RFIFOW(fd,58));
+ ShowInfo("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (ip: %s)\n",
+ server_name, CONVIP(server_ip), server_port, ip);
+ jstrescapecpy(t_uid, server_name);
+ if (login_config.log_login)
{
- char* server_name;
- uint32 server_ip;
- uint16 server_port;
-
- WFIFOHEAD(fd,3);
- memcpy(account.userid,RFIFOP(fd,2),NAME_LENGTH); account.userid[23] = '\0';
- memcpy(account.passwd,RFIFOP(fd,26),NAME_LENGTH); account.passwd[23] = '\0';
- account.passwdenc = 0;
- server_name = (char*)RFIFOP(fd,60); server_name[20] = '\0';
- server_ip = ntohl(RFIFOL(fd,54));
- server_port = ntohs(RFIFOW(fd,58));
- ShowInfo("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (ip: %s)\n",
- server_name, CONVIP(server_ip), server_port, ip);
- jstrescapecpy(t_uid, server_name);
- if (login_config.log_login)
- {
- char t_login[50];
- jstrescapecpy(t_login,account.userid);
- sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s@%s','100', 'charserver - %s@%u.%u.%u.%u:%d')",
- loginlog_db, ipl, t_login, t_uid, t_uid, CONVIP(server_ip), server_port);
+ char t_login[50];
+ jstrescapecpy(t_login,account.userid);
+ sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s@%s','100', 'charserver - %s@%u.%u.%u.%u:%d')",
+ loginlog_db, ipl, t_login, t_uid, t_uid, CONVIP(server_ip), server_port);
- //query
- if(mysql_query(&mysql_handle, tmpsql)) {
- ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
- }
+ //query
+ if(mysql_query(&mysql_handle, tmpsql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
}
+ }
- result = mmo_auth(&account, fd);
- if (result == -1 && account.sex == 2 && account.account_id < MAX_SERVERS && server_fd[account.account_id] == -1) {
- ShowStatus("Connection of the char-server '%s' accepted.\n", server_name);
- memset(&server[account.account_id], 0, sizeof(struct mmo_char_server));
- server[account.account_id].ip = ntohl(RFIFOL(fd,54));
- server[account.account_id].port = ntohs(RFIFOW(fd,58));
- memcpy(server[account.account_id].name, server_name, 20);
- server[account.account_id].users = 0;
- server[account.account_id].maintenance = RFIFOW(fd,82);
- server[account.account_id].new_ = RFIFOW(fd,84);
- server_fd[account.account_id] = fd;
- sprintf(tmpsql,"DELETE FROM `sstatus` WHERE `index`='%d'", account.account_id);
- //query
- if(mysql_query(&mysql_handle, tmpsql)) {
- ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
- }
-
- sprintf(tmpsql,"INSERT INTO `sstatus`(`index`,`name`,`user`) VALUES ( '%d', '%s', '%d')",
- account.account_id, t_uid,0);
- //query
- if(mysql_query(&mysql_handle, tmpsql)) {
- ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
- }
- WFIFOW(fd,0) = 0x2711;
- WFIFOB(fd,2) = 0;
- WFIFOSET(fd,3);
- session[fd]->func_parse = parse_fromchar;
- realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
- // send GM account to char-server
- send_GM_accounts(fd);
- } else {
- WFIFOW(fd,0) = 0x2711;
- WFIFOB(fd,2) = 3;
- WFIFOSET(fd,3);
+ result = mmo_auth(&account, fd);
+ if (result == -1 && account.sex == 2 && account.account_id < MAX_SERVERS && server_fd[account.account_id] == -1) {
+ ShowStatus("Connection of the char-server '%s' accepted.\n", server_name);
+ memset(&server[account.account_id], 0, sizeof(struct mmo_char_server));
+ server[account.account_id].ip = ntohl(RFIFOL(fd,54));
+ server[account.account_id].port = ntohs(RFIFOW(fd,58));
+ memcpy(server[account.account_id].name, server_name, 20);
+ server[account.account_id].users = 0;
+ server[account.account_id].maintenance = RFIFOW(fd,82);
+ server[account.account_id].new_ = RFIFOW(fd,84);
+ server_fd[account.account_id] = fd;
+ sprintf(tmpsql,"DELETE FROM `sstatus` WHERE `index`='%d'", account.account_id);
+ //query
+ if(mysql_query(&mysql_handle, tmpsql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
+ }
+
+ sprintf(tmpsql,"INSERT INTO `sstatus`(`index`,`name`,`user`) VALUES ( '%d', '%s', '%d')",
+ account.account_id, t_uid,0);
+ //query
+ if(mysql_query(&mysql_handle, tmpsql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
}
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x2711;
+ WFIFOB(fd,2) = 0;
+ WFIFOSET(fd,3);
+ session[fd]->func_parse = parse_fromchar;
+ realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+
+ send_GM_accounts(fd); // send GM account to char-server
+ } else {
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x2711;
+ WFIFOB(fd,2) = 3;
+ WFIFOSET(fd,3);
}
+
RFIFOSKIP(fd,86);
return 0;
+ }
case 0x7530: // Server version information request
{
@@ -1649,14 +1660,15 @@ int parse_login(int fd)
WFIFOB(fd,7) = ATHENA_SERVER_LOGIN;
WFIFOW(fd,8) = ATHENA_MOD_VERSION;
WFIFOSET(fd,10);
+
RFIFOSKIP(fd,2);
- break;
}
+ break;
case 0x7532: // Request to end connection
ShowStatus ("End of connection (ip: %s)" RETCODE, ip);
set_eof(fd);
- break;
+ break;
default:
ShowStatus ("Abnormal end of connection (ip: %s): Unknown packet 0x%x " RETCODE, ip, RFIFOW(fd,0));
diff --git a/src/login_sql/login.h b/src/login_sql/login.h
index abd28daef..086a50515 100644
--- a/src/login_sql/login.h
+++ b/src/login_sql/login.h
@@ -13,12 +13,6 @@
// supported encryption types: 1- passwordencrypt, 2- passwordencrypt2, 3- both
#define PASSWORDENC 3
-#ifndef SQL_DEBUG
- #define mysql_query(_x, _y) mysql_query(_x, _y)
-#else
- #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-#endif
-
struct mmo_account {
int version;
char userid[NAME_LENGTH];
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 3d0eabfd5..ba11565b7 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -207,7 +207,7 @@ int chrif_save(struct map_session_data *sd, int flag)
int chrif_connect(int fd)
{
ShowStatus("Logging in to char server...\n", char_fd);
- WFIFOHEAD(fd, 60);
+ WFIFOHEAD(fd,60);
WFIFOW(fd,0) = 0x2af8;
memcpy(WFIFOP(fd,2), userid, NAME_LENGTH);
memcpy(WFIFOP(fd,26), passwd, NAME_LENGTH);
@@ -240,7 +240,6 @@ int chrif_recvmap(int fd)
int i, j;
uint32 ip;
uint16 port;
- RFIFOHEAD(fd);
ip = ntohl(RFIFOL(fd,4));
port = ntohs(RFIFOW(fd,8));
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
@@ -259,7 +258,6 @@ int chrif_removemap(int fd)
int i, j;
uint32 ip;
uint16 port;
- RFIFOHEAD(fd);
ip = RFIFOL(fd, 4);
port = RFIFOW(fd, 8);
@@ -278,7 +276,6 @@ int chrif_removemap(int fd)
int chrif_save_ack(int fd)
{
struct map_session_data *sd;
- RFIFOHEAD(fd);
sd = map_id2sd(RFIFOL(fd,2));
if (sd && sd->status.char_id == RFIFOL(fd,6))
@@ -306,7 +303,7 @@ int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y,
else //Not connected? Can't retrieve IP
s_ip = 0;
- WFIFOHEAD(char_fd, 35);
+ WFIFOHEAD(char_fd,35);
WFIFOW(char_fd, 0) = 0x2b05;
WFIFOL(char_fd, 2) = sd->bl.id;
WFIFOL(char_fd, 6) = sd->login_id1;
@@ -329,7 +326,6 @@ int chrif_changemapserverack(int fd)
{
struct map_session_data *sd;
char mapname[MAP_NAME_LENGTH_EXT];
- RFIFOHEAD(fd);
sd = map_id2sd(RFIFOL(fd,2));
if (sd == NULL || sd->status.char_id != RFIFOL(fd,14))
@@ -355,7 +351,6 @@ int chrif_changemapserverack(int fd)
*------------------------------------------*/
int chrif_connectack(int fd)
{
- RFIFOHEAD(fd);
if (RFIFOB(fd,2)) {
ShowFatalError("Connection to char-server failed %d.\n", RFIFOB(fd,2));
exit(1);
@@ -381,7 +376,6 @@ int chrif_connectack(int fd)
*------------------------------------------*/
int chrif_sendmapack(int fd)
{
- RFIFOHEAD(fd);
if (RFIFOB(fd,2)) {
ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2));
exit(1);
@@ -408,10 +402,10 @@ int chrif_scdata_request(int account_id, int char_id)
#ifdef ENABLE_SC_SAVING
chrif_check(-1);
- WFIFOHEAD(char_fd, 10);
- WFIFOW(char_fd, 0) = 0x2afc;
- WFIFOL(char_fd, 2) = account_id;
- WFIFOL(char_fd, 6) = char_id;
+ WFIFOHEAD(char_fd,10);
+ WFIFOW(char_fd,0) = 0x2afc;
+ WFIFOL(char_fd,2) = account_id;
+ WFIFOL(char_fd,6) = char_id;
WFIFOSET(char_fd,10);
#endif
return 0;
@@ -455,7 +449,6 @@ void chrif_authok(int fd)
{
struct auth_node *auth_data;
TBL_PC* sd;
- RFIFOHEAD(fd);
//Check if we don't already have player data in our server
//(prevents data that is to be saved from being overwritten by
//this received status data if this auth is later successful) [Skotlex]
@@ -535,7 +528,7 @@ int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip)
return -1;
chrif_check(-1);
- WFIFOHEAD(char_fd, 18);
+ WFIFOHEAD(char_fd,18);
WFIFOW(char_fd, 0) = 0x2b02;
WFIFOL(char_fd, 2) = sd->bl.id;
WFIFOL(char_fd, 6) = sd->login_id1;
@@ -555,7 +548,7 @@ int chrif_searchcharid(int char_id)
return -1;
chrif_check(-1);
- WFIFOHEAD(char_fd, 6);
+ WFIFOHEAD(char_fd,6);
WFIFOW(char_fd,0) = 0x2b08;
WFIFOL(char_fd,2) = char_id;
WFIFOSET(char_fd,6);
@@ -593,7 +586,7 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email)
chrif_check(-1);
- WFIFOHEAD(char_fd, 86);
+ WFIFOHEAD(char_fd,86);
WFIFOW(char_fd,0) = 0x2b0c;
WFIFOL(char_fd,2) = id;
memcpy(WFIFOP(char_fd,6), actual_email, 40);
@@ -643,7 +636,7 @@ int chrif_changesex(int id, int sex)
{
chrif_check(-1);
- WFIFOHEAD(char_fd, 9);
+ WFIFOHEAD(char_fd,9);
WFIFOW(char_fd,0) = 0x2b11;
WFIFOW(char_fd,2) = 9;
WFIFOL(char_fd,4) = id;
@@ -673,7 +666,6 @@ int chrif_char_ask_name_answer(int fd)
struct map_session_data *sd;
char output[256];
char player_name[NAME_LENGTH];
- RFIFOHEAD(fd);
acc = RFIFOL(fd,2); // account_id of who has asked (-1 if nobody)
memcpy(player_name, RFIFOP(fd,6), NAME_LENGTH-1);
@@ -774,7 +766,6 @@ int chrif_changedgm(int fd)
{
int acc, level;
struct map_session_data *sd = NULL;
- RFIFOHEAD(fd);
acc = RFIFOL(fd,2);
level = RFIFOL(fd,6);
@@ -800,7 +791,6 @@ int chrif_changedsex(int fd)
{
int acc, sex, i;
struct map_session_data *sd;
- RFIFOHEAD(fd);
acc = RFIFOL(fd,2);
sex = RFIFOL(fd,6);
@@ -896,7 +886,6 @@ int chrif_accountdeletion(int fd)
{
int acc;
struct map_session_data *sd;
- RFIFOHEAD(fd);
acc = RFIFOL(fd,2);
if (battle_config.etc_log)
@@ -923,7 +912,6 @@ int chrif_accountban(int fd)
{
int acc;
struct map_session_data *sd;
- RFIFOHEAD(fd);
acc = RFIFOL(fd,2);
if (battle_config.etc_log)
@@ -991,7 +979,6 @@ int chrif_accountban(int fd)
int chrif_disconnectplayer(int fd)
{
struct map_session_data *sd;
- RFIFOHEAD(fd);
sd = map_id2sd(RFIFOL(fd, 2));
@@ -1040,9 +1027,9 @@ int chrif_reloadGMdb(void)
{
chrif_check(-1);
- WFIFOHEAD(char_fd, 2);
+ WFIFOHEAD(char_fd,2);
WFIFOW(char_fd,0) = 0x2af7;
- WFIFOSET(char_fd, 2);
+ WFIFOSET(char_fd,2);
return 0;
}
@@ -1080,12 +1067,12 @@ int chrif_updatefamelist(struct map_session_data *sd)
}
WFIFOHEAD(char_fd, 12);
- WFIFOW(char_fd, 0) = 0x2b10;
- WFIFOL(char_fd, 2) = sd->status.char_id;
- WFIFOL(char_fd, 6) = sd->status.fame;
- WFIFOB(char_fd, 10) = type;
- WFIFOB(char_fd, 11) = pc_famerank(sd->status.char_id, sd->class_&MAPID_UPPERMASK);
- WFIFOSET(char_fd, 12);
+ WFIFOW(char_fd,0) = 0x2b10;
+ WFIFOL(char_fd,2) = sd->status.char_id;
+ WFIFOL(char_fd,6) = sd->status.fame;
+ WFIFOB(char_fd,10) = type;
+ WFIFOB(char_fd,11) = pc_famerank(sd->status.char_id, sd->class_&MAPID_UPPERMASK);
+ WFIFOSET(char_fd,12);
return 0;
}
@@ -1094,9 +1081,9 @@ int chrif_buildfamelist(void)
{
chrif_check(-1);
- WFIFOHEAD(char_fd, 2);
- WFIFOW(char_fd, 0) = 0x2b1a;
- WFIFOSET(char_fd, 2);
+ WFIFOHEAD(char_fd,2);
+ WFIFOW(char_fd,0) = 0x2b1a;
+ WFIFOSET(char_fd,2);
return 0;
}
@@ -1105,7 +1092,6 @@ int chrif_recvfamelist(int fd)
{
int num, size;
int total = 0, len = 8;
- RFIFOHEAD(fd);
memset (smith_fame_list, 0, sizeof(smith_fame_list));
memset (chemist_fame_list, 0, sizeof(chemist_fame_list));
@@ -1141,7 +1127,6 @@ int chrif_updatefamelist_ack(int fd)
{
struct fame_list *list;
char index;
- RFIFOHEAD(fd);
switch (RFIFOB(fd, 2))
{
case 1:
@@ -1213,7 +1198,6 @@ int chrif_load_scdata(int fd)
struct map_session_data *sd;
struct status_change_data *data;
int aid, cid, i, count;
- RFIFOHEAD(fd);
aid = RFIFOL(fd,4); //Player Account ID
cid = RFIFOL(fd,8); //Player Char ID
@@ -1290,7 +1274,7 @@ int chrif_char_offline(struct map_session_data *sd)
{
chrif_check(-1);
- WFIFOHEAD(char_fd, 10);
+ WFIFOHEAD(char_fd,10);
WFIFOW(char_fd,0) = 0x2b17;
WFIFOL(char_fd,2) = sd->status.char_id;
WFIFOL(char_fd,6) = sd->status.account_id;
@@ -1320,7 +1304,7 @@ int chrif_char_reset_offline(void)
{
chrif_check(-1);
- WFIFOHEAD(char_fd, 2);
+ WFIFOHEAD(char_fd,2);
WFIFOW(char_fd,0) = 0x2b18;
WFIFOSET(char_fd,2);
@@ -1335,7 +1319,7 @@ int chrif_char_online(struct map_session_data *sd)
{
chrif_check(-1);
- WFIFOHEAD(char_fd, 10);
+ WFIFOHEAD(char_fd,10);
WFIFOW(char_fd,0) = 0x2b19;
WFIFOL(char_fd,2) = sd->status.char_id;
WFIFOL(char_fd,6) = sd->status.account_id;
@@ -1363,16 +1347,16 @@ int chrif_disconnect(int fd)
void chrif_update_ip(int fd)
{
uint32 new_ip;
- WFIFOHEAD(fd, 6);
+ WFIFOHEAD(fd,6);
new_ip = host2ip(char_ip_str);
if (new_ip && new_ip != char_ip)
char_ip = new_ip; //Update char_ip
new_ip = clif_refresh_ip();
if (!new_ip) return; //No change
- WFIFOW(fd, 0) = 0x2736;
- WFIFOL(fd, 2) = htonl(new_ip);
- WFIFOSET(fd, 6);
+ WFIFOW(fd,0) = 0x2736;
+ WFIFOL(fd,2) = htonl(new_ip);
+ WFIFOSET(fd,6);
}
/*==========================================
@@ -1395,7 +1379,6 @@ int chrif_parse(int fd)
}
while (RFIFOREST(fd) >= 2) { //Infinite loop on broken pipe fix. [Skotlex]
- RFIFOHEAD(fd);
cmd = RFIFOW(fd,0);
if (cmd < 0x2af8 || cmd >= 0x2af8 + (sizeof(packet_len_table) / sizeof(packet_len_table[0])) ||
packet_len_table[cmd-0x2af8] == 0) {
@@ -1469,7 +1452,7 @@ int send_usercount_tochar(int tid, unsigned int tick, int id, int data)
return 0;
last_count = count;
- WFIFOHEAD(char_fd, 4);
+ WFIFOHEAD(char_fd,4);
WFIFOW(char_fd,0) = 0x2afe;
WFIFOW(char_fd,2) = count;
WFIFOSET(char_fd,4);
diff --git a/src/map/clif.c b/src/map/clif.c
index 9c3345895..fd5f69bd0 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -711,9 +711,9 @@ int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type)
int clif_clearchar_id(int id, int type, int fd)
{
WFIFOHEAD(fd, packet_len(0x80));
- WFIFOW(fd,0) = 0x80;
- WFIFOL(fd,2) = id;
- WFIFOB(fd,6) = (char)type; // Why use int for a char in the first place?
+ WFIFOW(fd,0) = 0x80;
+ WFIFOL(fd,2) = id;
+ WFIFOB(fd,6) = (char)type; // Why use int for a char in the first place?
WFIFOSET(fd, packet_len(0x80));
return 0;
@@ -1876,13 +1876,13 @@ int clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes)
int fd = sd->fd;
int slen = strlen(mes) + 8;
struct block_list *bl = NULL;
- WFIFOHEAD(fd, slen);
if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
clif_sendfakenpc(sd, npcid);
+ WFIFOHEAD(fd, slen);
WFIFOW(fd,0)=0xb7;
WFIFOW(fd,2)=slen;
WFIFOL(fd,4)=npcid;
@@ -2041,8 +2041,6 @@ static void clif_addcards(unsigned char* buf, struct item* item)
int clif_additem(struct map_session_data *sd, int n, int amount, int fail)
{
int fd;
- unsigned char *buf;
-
nullpo_retr(0, sd);
fd = sd->fd;
@@ -2050,40 +2048,39 @@ int clif_additem(struct map_session_data *sd, int n, int amount, int fail)
return 0;
WFIFOHEAD(fd,packet_len(0xa0));
- buf = WFIFOP(fd,0);
if(fail) {
- WBUFW(buf,0)=0xa0;
- WBUFW(buf,2)=n+2;
- WBUFW(buf,4)=amount;
- WBUFW(buf,6)=0;
- WBUFB(buf,8)=0;
- WBUFB(buf,9)=0;
- WBUFB(buf,10)=0;
- WBUFW(buf,11)=0;
- WBUFW(buf,13)=0;
- WBUFW(buf,15)=0;
- WBUFW(buf,17)=0;
- WBUFW(buf,19)=0;
- WBUFB(buf,21)=0;
- WBUFB(buf,22)=fail;
+ WFIFOW(fd,0)=0xa0;
+ WFIFOW(fd,2)=n+2;
+ WFIFOW(fd,4)=amount;
+ WFIFOW(fd,6)=0;
+ WFIFOB(fd,8)=0;
+ WFIFOB(fd,9)=0;
+ WFIFOB(fd,10)=0;
+ WFIFOW(fd,11)=0;
+ WFIFOW(fd,13)=0;
+ WFIFOW(fd,15)=0;
+ WFIFOW(fd,17)=0;
+ WFIFOW(fd,19)=0;
+ WFIFOB(fd,21)=0;
+ WFIFOB(fd,22)=fail;
} else {
if (n<0 || n>=MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL)
return 1;
- WBUFW(buf,0)=0xa0;
- WBUFW(buf,2)=n+2;
- WBUFW(buf,4)=amount;
+ WFIFOW(fd,0)=0xa0;
+ WFIFOW(fd,2)=n+2;
+ WFIFOW(fd,4)=amount;
if (sd->inventory_data[n]->view_id > 0)
- WBUFW(buf,6)=sd->inventory_data[n]->view_id;
+ WFIFOW(fd,6)=sd->inventory_data[n]->view_id;
else
- WBUFW(buf,6)=sd->status.inventory[n].nameid;
- WBUFB(buf,8)=sd->status.inventory[n].identify;
- WBUFB(buf,9)=sd->status.inventory[n].attribute;
- WBUFB(buf,10)=sd->status.inventory[n].refine;
- clif_addcards(WBUFP(buf,11), &sd->status.inventory[n]);
- WBUFW(buf,19)=pc_equippoint(sd,n);
- WBUFB(buf,21)=itemtype(sd->inventory_data[n]->type);
- WBUFB(buf,22)=fail;
+ WFIFOW(fd,6)=sd->status.inventory[n].nameid;
+ WFIFOB(fd,8)=sd->status.inventory[n].identify;
+ WFIFOB(fd,9)=sd->status.inventory[n].attribute;
+ WFIFOB(fd,10)=sd->status.inventory[n].refine;
+ clif_addcards(WFIFOP(fd,11), &sd->status.inventory[n]);
+ WFIFOW(fd,19)=pc_equippoint(sd,n);
+ WFIFOB(fd,21)=itemtype(sd->inventory_data[n]->type);
+ WFIFOB(fd,22)=fail;
}
WFIFOSET(fd,packet_len(0xa0));
@@ -2104,7 +2101,6 @@ int clif_delitem(struct map_session_data *sd,int n,int amount)
WFIFOW(fd,0)=0xaf;
WFIFOW(fd,2)=n+2;
WFIFOW(fd,4)=amount;
-
WFIFOSET(fd,packet_len(0xaf));
return 0;
@@ -2894,7 +2890,6 @@ int clif_arrowequip(struct map_session_data *sd,int val)
WFIFOHEAD(fd, packet_len(0x013c));
WFIFOW(fd,0)=0x013c;
WFIFOW(fd,2)=val+2;//矢のアイテムID
-
WFIFOSET(fd,packet_len(0x013c));
return 0;
@@ -2917,7 +2912,6 @@ int clif_arrow_fail(struct map_session_data *sd,int type)
WFIFOHEAD(fd, packet_len(0x013b));
WFIFOW(fd,0)=0x013b;
WFIFOW(fd,2)=type;
-
WFIFOSET(fd,packet_len(0x013b));
return 0;
@@ -7850,7 +7844,6 @@ static int clif_guess_PacketVer(int fd, int get_previous, int *error)
static int err = 1;
static int packet_ver = -1;
int cmd, packet_len, value; //Value is used to temporarily store account/char_id/sex
- RFIFOHEAD(fd);
if (get_previous)
{//For quick reruns, since the normal code flow is to fetch this once to identify the packet version, then again in the wanttoconnect function. [Skotlex]
@@ -7916,7 +7909,6 @@ void clif_parse_WantToConnection(int fd, TBL_PC* sd)
int cmd, account_id, char_id, login_id1, sex;
unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex]
int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
- RFIFOHEAD(fd);
if (sd) {
if (battle_config.error_log)
@@ -8204,9 +8196,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_TickSend(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
- sd->client_tick=RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ sd->client_tick = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
WFIFOHEAD(fd, packet_len(0x7f));
WFIFOW(fd,0)=0x7f;
@@ -8224,7 +8214,6 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd)
{
int x, y;
int cmd;
- RFIFOHEAD(fd);
if (pc_isdead(sd)) {
clif_clearchar_area(&sd->bl, 1);
@@ -8373,7 +8362,6 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
int account_id;
struct block_list* bl;
struct status_change *sc;
- RFIFOHEAD(fd);
account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
@@ -8412,8 +8400,6 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
char* message;
unsigned int packetlen, messagelen, namelen;
- RFIFOHEAD(fd);
-
packetlen = RFIFOW(fd,2);
if (packetlen > RFIFOREST(fd)) { // there has to be enough data to read
ShowWarning("clif_parse_GlobalMessage: Received malformed packet from player '%s' (length is incorrect)!", sd->status.name);
@@ -8557,7 +8543,6 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd)
char output[MAP_NAME_LENGTH_EXT+15]; // Max length of a short: ' -6XXXX' -> 7 digits
char message[MAP_NAME_LENGTH_EXT+15+5]; // "/mm "+output
char *map_name;
- RFIFOHEAD(fd);
if (battle_config.atc_gmonly && !pc_isGM(sd))
return;
@@ -8604,7 +8589,6 @@ void clif_changed_dir(struct block_list *bl, int type)
void clif_parse_ChangeDir(int fd, struct map_session_data *sd)
{
unsigned char headdir, dir;
- RFIFOHEAD(fd);
headdir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
dir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
@@ -8620,7 +8604,6 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd)
void clif_parse_Emotion(int fd, struct map_session_data *sd)
{
unsigned char buf[64];
- RFIFOHEAD(fd);
if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
if (RFIFOB(fd,2) == 34) {// prevent use of the mute emote [Valaris]
@@ -8745,7 +8728,6 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
*------------------------------------------*/
void clif_parse_ActionRequest(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
clif_parse_ActionRequest_sub(sd,
RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]),
RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
@@ -8758,8 +8740,6 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_Restart(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
switch(RFIFOB(fd,2)) {
case 0x00:
if (!pc_isdead(sd))
@@ -8799,7 +8779,7 @@ void clif_parse_Wis(int fd, struct map_session_data *sd)
char target[NAME_LENGTH+1];
char output[256];
unsigned int len;
- RFIFOHEAD(fd);
+
len = RFIFOW(fd,2); //Packet length
if (len < 28)
{ //Invalid packet, specified size is less than minimum! [Skotlex]
@@ -8973,7 +8953,7 @@ void clif_parse_GMmessage(int fd, struct map_session_data *sd)
{
char* mes;
int size, lv;
- RFIFOHEAD(fd);
+
if (battle_config.atc_gmonly && !pc_isGM(sd))
return;
if (pc_isGM(sd) < (lv=get_atcommand_level(AtCommand_Broadcast)))
@@ -8998,7 +8978,6 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
{
struct flooritem_data *fitem;
int map_object_id;
- RFIFOHEAD(fd);
map_object_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
@@ -9041,7 +9020,6 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
void clif_parse_DropItem(int fd, struct map_session_data *sd)
{
int item_index, item_amount;
- RFIFOHEAD(fd);
if (pc_isdead(sd)) {
clif_clearchar_area(&sd->bl, 1);
@@ -9072,7 +9050,6 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd)
void clif_parse_UseItem(int fd, struct map_session_data *sd)
{
int n;
- RFIFOHEAD(fd);
if (pc_isdead(sd)) {
clif_clearchar_area(&sd->bl, 1);
@@ -9108,7 +9085,6 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd)
void clif_parse_EquipItem(int fd,struct map_session_data *sd)
{
int index;
- RFIFOHEAD(fd);
if(pc_isdead(sd)) {
clif_clearchar_area(&sd->bl,1);
@@ -9155,7 +9131,6 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd)
void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
{
int index;
- RFIFOHEAD(fd);
if(pc_isdead(sd)) {
clif_clearchar_area(&sd->bl,1);
@@ -9178,7 +9153,6 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
{
struct block_list *bl;
- RFIFOHEAD(fd);
if(pc_isdead(sd)) {
clif_clearchar_area(&sd->bl,1);
@@ -9210,7 +9184,6 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (sd->state.trading)
return;
npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
@@ -9223,7 +9196,6 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
{
int fail=0,n;
unsigned short *item_list;
- RFIFOHEAD(fd);
n = (RFIFOW(fd,2)-4) /4;
item_list = (unsigned short*)RFIFOP(fd,4);
@@ -9247,7 +9219,6 @@ void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
{
int fail=0,n;
unsigned short *item_list;
- RFIFOHEAD(fd);
n = (RFIFOW(fd,2)-4) /4;
item_list = (unsigned short*)RFIFOP(fd,4);
@@ -9270,7 +9241,6 @@ void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM)
return;
if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 4){
@@ -9284,7 +9254,6 @@ void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ChatAddMember(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
chat_joinchat(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
}
@@ -9293,7 +9262,6 @@ void clif_parse_ChatAddMember(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
chat_changechatstatus(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
}
@@ -9302,7 +9270,6 @@ void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
chat_changechatowner(sd,(char*)RFIFOP(fd,6));
}
@@ -9311,7 +9278,6 @@ void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
chat_kickchat(sd,(char*)RFIFOP(fd,2));
}
@@ -9344,7 +9310,6 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
{
struct map_session_data *t_sd;
- RFIFOHEAD(fd);
t_sd = map_id2sd(RFIFOL(fd,2));
if(!sd->chatID && clif_cant_act(sd))
@@ -9367,7 +9332,6 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_TradeAck(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
trade_tradeack(sd,RFIFOB(fd,2));
}
@@ -9376,7 +9340,6 @@ void clif_parse_TradeAck(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
trade_tradeadditem(sd,RFIFOW(fd,2),RFIFOL(fd,4));
}
@@ -9417,8 +9380,6 @@ void clif_parse_StopAttack(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if (clif_trading(sd))
return;
if (!pc_iscarton(sd))
@@ -9430,7 +9391,6 @@ void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (!pc_iscarton(sd))
return;
pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
@@ -9452,7 +9412,6 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
{
int type;
- RFIFOHEAD(fd);
type = (int)RFIFOW(fd,2);
if( (type == 5 && sd->status.base_level <= 90) ||
@@ -9470,7 +9429,6 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_StatusUp(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
pc_statusup(sd,RFIFOW(fd,2));
}
@@ -9479,7 +9437,6 @@ void clif_parse_StatusUp(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_SkillUp(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
pc_skillup(sd,RFIFOW(fd,2));
}
@@ -9518,7 +9475,6 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
{
int skillnum, skilllv, tmp, target_id;
unsigned int tick = gettick();
- RFIFOHEAD(fd);
if (clif_cant_act(sd))
return;
@@ -9634,7 +9590,6 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, int skilll
{
int lv;
unsigned int tick = gettick();
- RFIFOHEAD(fd);
//Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
sd->idletime = last_tick;
@@ -9694,8 +9649,6 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, int skilll
void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if (clif_cant_act(sd))
return;
if (pc_issit(sd))
@@ -9712,8 +9665,6 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd)
void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if (clif_cant_act(sd))
return;
if (pc_issit(sd))
@@ -9733,7 +9684,6 @@ void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd)
void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
{
int skill_num;
- RFIFOHEAD(fd);
skill_num = RFIFOW(fd,2);
if(skill_num != sd->menuskill_id)
@@ -9761,8 +9711,6 @@ void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if (sd->menuskill_id != AM_PHARMACY)
return;
@@ -9780,8 +9728,6 @@ void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_RepairItem(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if (sd->menuskill_id != BS_REPAIRWEAPON)
return;
if (clif_trading(sd)) {
@@ -9800,7 +9746,6 @@ void clif_parse_RepairItem(int fd, struct map_session_data *sd)
void clif_parse_WeaponRefine(int fd, struct map_session_data *sd)
{
int idx;
- RFIFOHEAD(fd);
if (sd->menuskill_id != WS_WEAPONREFINE) //Packet exploit?
return;
@@ -9821,7 +9766,6 @@ void clif_parse_WeaponRefine(int fd, struct map_session_data *sd)
void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
{
uint8 select;
- RFIFOHEAD(fd);
select = RFIFOB(fd,6);
if((select > sd->npc_menu && select != 0xff) || !select){
@@ -9838,7 +9782,6 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
npc_scriptcont(sd,RFIFOL(fd,2));
}
@@ -9847,7 +9790,6 @@ void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
sd->npc_amount=(int)RFIFOL(fd,6);
npc_scriptcont(sd,RFIFOL(fd,2));
}
@@ -9858,7 +9800,6 @@ void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
void clif_parse_NpcStringInput(int fd,struct map_session_data *sd)
{
short message_len;
- RFIFOHEAD(fd);
message_len = RFIFOW(fd,2)-7;
if(message_len < 1)
@@ -9880,9 +9821,9 @@ void clif_parse_NpcStringInput(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
- if (sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
- npc_scriptcont(sd,RFIFOL(fd,2));
+ if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
+ return;
+ npc_scriptcont(sd,RFIFOL(fd,2));
}
/*==========================================
@@ -9890,7 +9831,6 @@ void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (sd->menuskill_id != MC_IDENTIFY)
return;
skill_identify(sd,RFIFOW(fd,2)-2);
@@ -9901,7 +9841,6 @@ void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (sd->menuskill_id != AC_MAKINGARROW)
return;
if (clif_trading(sd)) {
@@ -9918,7 +9857,6 @@ void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (sd->menuskill_id != SA_AUTOSPELL)
return;
skill_autospell(sd,RFIFOW(fd,2));
@@ -9929,8 +9867,7 @@ void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_UseCard(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
- if (sd->state.trading!= 0)
+ if (sd->state.trading != 0)
return;
clif_use_card(sd,RFIFOW(fd,2)-2);
}
@@ -9939,8 +9876,7 @@ void clif_parse_UseCard(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_InsertCard(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
- if (sd->state.trading!= 0)
+ if (sd->state.trading != 0)
return;
pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
}
@@ -9951,7 +9887,6 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd)
void clif_parse_SolveCharName(int fd, struct map_session_data *sd)
{
int char_id;
- RFIFOHEAD(fd);
char_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
clif_solved_charname(sd, char_id);
@@ -9962,7 +9897,6 @@ void clif_parse_SolveCharName(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ResetChar(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (battle_config.atc_gmonly && !pc_isGM(sd))
return;
if (pc_isGM(sd) < get_atcommand_level(AtCommand_ResetState))
@@ -9985,7 +9919,6 @@ void clif_parse_LGMmessage(int fd, struct map_session_data *sd)
unsigned char buf[CHAT_SIZE+4];
char *mes;
int len, lv;
- RFIFOHEAD(fd);
if (battle_config.atc_gmonly && !pc_isGM(sd))
return;
@@ -10013,7 +9946,6 @@ void clif_parse_LGMmessage(int fd, struct map_session_data *sd)
void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
{
int item_index, item_amount;
- RFIFOHEAD(fd);
if (clif_trading(sd))
return;
@@ -10035,7 +9967,6 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd)
{
int item_index, item_amount;
- RFIFOHEAD(fd);
item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-1;
item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
@@ -10051,8 +9982,6 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if(sd->vender_id)
return;
if (!pc_iscarton(sd))
@@ -10068,8 +9997,6 @@ void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if (sd->vender_id)
return;
if (!pc_iscarton(sd))
@@ -10105,7 +10032,6 @@ void clif_parse_StoragePassword(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_CreateParty(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if(map[sd->bl.m].flag.partylock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(227));
@@ -10127,10 +10053,9 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd)
clif_displaymessage(fd, msg_txt(227));
return;
}
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7){
- RFIFOHEAD(fd);
+ if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7)
party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27));
- } else
+ else
clif_skill_fail(sd,1,0,4);
}
@@ -10141,7 +10066,6 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd)
{
struct map_session_data *t_sd;
- RFIFOHEAD(fd);
if(map[sd->bl.m].flag.partylock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(227));
@@ -10164,7 +10088,6 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 5){
party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
} else {
@@ -10191,7 +10114,6 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if(map[sd->bl.m].flag.partylock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(227));
@@ -10206,7 +10128,6 @@ void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd)
void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd)
{
struct party_data *p;
- RFIFOHEAD(fd);
if(!sd->status.party_id)
return;
@@ -10227,7 +10148,6 @@ void clif_parse_PartyMessage(int fd, struct map_session_data *sd)
char *mes;
int len;
- RFIFOHEAD(fd);
len = RFIFOW(fd,2) - 4;
mes = RFIFOP(fd,4);
mes_len_check(mes, len, CHAT_SIZE);
@@ -10265,8 +10185,6 @@ void clif_parse_CloseVending(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_VendingListReq(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
vending_vendinglistreq(sd,RFIFOL(fd,2));
if(sd->npc_id)
npc_event_dequeue(sd);
@@ -10277,7 +10195,6 @@ void clif_parse_VendingListReq(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_PurchaseReq(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
vending_purchasereq(sd, RFIFOW(fd,2), RFIFOL(fd,4), RFIFOP(fd,8));
}
@@ -10286,7 +10203,6 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_OpenVending(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (clif_trading(sd))
return;
if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM)
@@ -10299,7 +10215,6 @@ void clif_parse_OpenVending(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_CreateGuild(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if(map[sd->bl.m].flag.guildlock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(228));
@@ -10321,8 +10236,8 @@ void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
- if (!sd->status.guild_id) return;
+ if (!sd->status.guild_id)
+ return;
switch(RFIFOL(fd,2)){
case 0: // ギルド基本情報、同盟敵対情報
clif_guild_basicinfo(sd);
@@ -10355,7 +10270,6 @@ void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd)
void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd)
{
int i;
- RFIFOHEAD(fd);
if(!sd->state.gmaster_flag)
return;
@@ -10371,7 +10285,6 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd)
void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd)
{
int i;
- RFIFOHEAD(fd);
if(!sd->state.gmaster_flag)
return;
@@ -10387,9 +10300,7 @@ void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd)
{
- struct guild *g;
- RFIFOHEAD(fd);
- g=guild_search(RFIFOL(fd,2));
+ struct guild* g = guild_search(RFIFOL(fd,2));
if(g!=NULL)
clif_guild_emblem(sd,g);
}
@@ -10399,8 +10310,6 @@ void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if(!sd->state.gmaster_flag)
return;
@@ -10412,8 +10321,6 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if(!sd->state.gmaster_flag)
return;
@@ -10439,8 +10346,6 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd)
{
struct map_session_data *t_sd;
- RFIFOHEAD(fd);
-
if(map[sd->bl.m].flag.guildlock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(228));
@@ -10463,7 +10368,6 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
guild_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
}
@@ -10472,7 +10376,6 @@ void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildLeave(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if(map[sd->bl.m].flag.guildlock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(228));
@@ -10486,7 +10389,6 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if(map[sd->bl.m].flag.guildlock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(228));
@@ -10503,7 +10405,6 @@ void clif_parse_GuildMessage(int fd,struct map_session_data *sd)
char *mes;
int len;
- RFIFOHEAD(fd);
len = RFIFOW(fd,2) - 4;
mes = RFIFOP(fd,4);
mes_len_check(mes, len, CHAT_SIZE);
@@ -10535,8 +10436,6 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd)
{
struct map_session_data *t_sd;
- RFIFOHEAD(fd);
-
if(!sd->state.gmaster_flag)
return;
@@ -10562,7 +10461,6 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
}
@@ -10571,8 +10469,6 @@ void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
-
if(!sd->state.gmaster_flag)
return;
@@ -10590,7 +10486,6 @@ void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd)
void clif_parse_GuildOpposition(int fd, struct map_session_data *sd)
{
struct map_session_data *t_sd;
- RFIFOHEAD(fd);
if(!sd->state.gmaster_flag)
return;
@@ -10617,7 +10512,6 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_GuildBreak(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if(map[sd->bl.m].flag.guildlock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(228));
@@ -10629,19 +10523,16 @@ void clif_parse_GuildBreak(int fd, struct map_session_data *sd)
// pet
void clif_parse_PetMenu(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
pet_menu(sd,RFIFOB(fd,2));
}
void clif_parse_CatchPet(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
pet_catch_process2(sd,RFIFOL(fd,2));
}
void clif_parse_SelectEgg(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_lv != -1)
return;
pet_select_egg(sd,RFIFOW(fd,2)-2);
@@ -10650,15 +10541,12 @@ void clif_parse_SelectEgg(int fd, struct map_session_data *sd)
void clif_parse_SendEmotion(int fd, struct map_session_data *sd)
{
- if(sd->pd) {
- RFIFOHEAD(fd);
+ if(sd->pd)
clif_pet_emotion(sd->pd,RFIFOL(fd,2));
- }
}
void clif_parse_ChangePetName(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
pet_change_name(sd,(char*)RFIFOP(fd,2));
}
@@ -10668,7 +10556,6 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
struct block_list *target;
int tid,lv;
- RFIFOHEAD(fd);
if (battle_config.atc_gmonly && !pc_isGM(sd))
return;
@@ -10724,7 +10611,6 @@ void clif_parse_Shift(int fd, struct map_session_data *sd)
if (pc_isGM(sd) < (lv=get_atcommand_level(AtCommand_JumpTo)))
return;
- RFIFOHEAD(fd);
player_name = RFIFOP(fd,2);
player_name[NAME_LENGTH-1] = '\0';
atcommand_jumpto(fd, sd, "@jumpto", player_name); // as @jumpto
@@ -10750,7 +10636,6 @@ void clif_parse_Recall(int fd, struct map_session_data *sd)
if (pc_isGM(sd) < (lv=get_atcommand_level(AtCommand_Recall)))
return;
- RFIFOHEAD(fd);
player_name = RFIFOP(fd,2);
player_name[NAME_LENGTH-1] = '\0';
atcommand_recall(fd, sd, "@recall", player_name); // as @recall
@@ -10770,7 +10655,6 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
char *monster_item_name;
char message[NAME_LENGTH+10]; //For logging.
int level;
- RFIFOHEAD(fd);
if (battle_config.atc_gmonly && !pc_isGM(sd))
return;
@@ -10837,7 +10721,6 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
struct block_list *bl;
struct map_session_data *dstsd;
- RFIFOHEAD(fd);
bl = map_id2bl(RFIFOL(fd,2));
if (!bl || bl->type != BL_PC)
return;
@@ -10875,14 +10758,12 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *sd)
{
int tid;
- RFIFOHEAD(fd);
tid = RFIFOL(fd,2);
WFIFOHEAD(fd,packet_len(0x1e0));
WFIFOW(fd,0) = 0x1e0;
WFIFOL(fd,2) = tid;
sprintf((char*)WFIFOP(fd,6),"%d",tid);
-// memcpy(WFIFOP(fd,6), "TESTNAME", 24);
WFIFOSET(fd, packet_len(0x1e0));
return;
@@ -10907,14 +10788,13 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd)
char output[512];
char *nick; // S 00cf <nick>.24B <type>.B: 00 (/ex nick) deny speech from nick, 01 (/in nick) allow speech from nick
int i;
- WFIFOHEAD(fd,packet_len(0xd1));
- RFIFOHEAD(fd);
memset(output, '\0', sizeof(output));
nick = (char*)RFIFOP(fd,2); // speed up
nick[NAME_LENGTH-1] = '\0'; // to be sure that the player name have at maximum 23 characters
+ WFIFOHEAD(fd,packet_len(0xd1));
WFIFOW(fd,0) = 0x0d1; // R 00d1 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
WFIFOB(fd,2) = RFIFOB(fd,26);
// deny action (we add nick only if it's not already exist
@@ -10990,10 +10870,9 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd)
void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd)
{
//printf("Ignore all: state: %d\n", RFIFOB(fd,2));
- RFIFOHEAD(fd);
- WFIFOHEAD(fd,packet_len(0xd2));
// R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
// S 00d0 <type>len.B: 00 (/exall) deny all speech, 01 (/inall) allow all speech
+ WFIFOHEAD(fd,packet_len(0xd2));
WFIFOW(fd,0) = 0x0d2;
WFIFOB(fd,2) = RFIFOB(fd,2);
if (RFIFOB(fd,2) == 0) { //Deny all
@@ -11176,7 +11055,6 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd)
{
struct map_session_data *f_sd;
int i, f_fd;
- RFIFOHEAD(fd);
f_sd = map_nick2sd((char*)RFIFOP(fd,2));
@@ -11223,7 +11101,6 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd)
struct map_session_data *f_sd;
int char_id, account_id;
char reply;
- RFIFOHEAD(fd);
account_id = RFIFOL(fd,2);
char_id = RFIFOL(fd,6);
@@ -11280,7 +11157,6 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
// 0x203 </o> <ID to be removed W 4B>
int account_id, char_id;
int i, j;
- RFIFOHEAD(fd);
account_id = RFIFOL(fd,2);
char_id = RFIFOL(fd,6);
@@ -11528,7 +11404,6 @@ void clif_parse_AdoptRequest(int fd,struct map_session_data *sd)
//[Skotlex]
int account_id;
struct map_session_data *sd2;
- RFIFOHEAD(fd);
account_id = RFIFOL(fd,2);
sd2 = map_id2sd(account_id);
@@ -11546,7 +11421,6 @@ void clif_parse_AdoptRequest(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd)
{
- RFIFOHEAD(fd);
merc_hom_change_name(sd,RFIFOP(fd,2));
}
@@ -11563,7 +11437,6 @@ void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd)
void clif_parse_HomMoveTo(int fd,struct map_session_data *sd)
{ //[orn]
int x,y,cmd;
- RFIFOHEAD(fd);
nullpo_retv(sd);
if(!merc_is_hom_active(sd->hd))
@@ -11580,8 +11453,6 @@ void clif_parse_HomMoveTo(int fd,struct map_session_data *sd)
void clif_parse_HomAttack(int fd,struct map_session_data *sd)
{ //[orn]
- RFIFOHEAD(fd);
-
if(!merc_is_hom_active(sd->hd))
return;
@@ -11592,7 +11463,6 @@ void clif_parse_HomMenu(int fd, struct map_session_data *sd)
{ //[orn]
int cmd;
- RFIFOHEAD(fd);
cmd = RFIFOW(fd,0);
if(!merc_is_hom_active(sd->hd))
@@ -11607,7 +11477,6 @@ void clif_parse_HomMenu(int fd, struct map_session_data *sd)
void clif_parse_debug(int fd,struct map_session_data *sd)
{
int i, cmd, len;
- RFIFOHEAD(fd);
cmd = RFIFOW(fd,0);
len = sd?packet_db[sd->packet_ver][cmd].len:RFIFOREST(fd); //With no session, just read the remaining in the buffer.
@@ -11629,7 +11498,6 @@ int clif_parse(int fd)
{
int packet_len = 0, cmd, packet_ver, err, dump = 0;
TBL_PC *sd;
- RFIFOHEAD(fd);
sd = (TBL_PC *)session[fd]->session_data;
if (session[fd]->eof) {
diff --git a/src/map/intif.c b/src/map/intif.c
index 8b8bcf08c..92c234c56 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -413,7 +413,6 @@ int intif_party_addmember(int party_id,struct party_member *member)
{
if (CheckForCharServer())
return 0;
-
WFIFOHEAD(inter_fd,42);
WFIFOW(inter_fd,0)=0x3022;
WFIFOW(inter_fd,2)=8+sizeof(struct party_member);
@@ -849,7 +848,7 @@ int intif_parse_WisMessage(int fd)
char *wisp_source;
char name[NAME_LENGTH];
int id, i;
- RFIFOHEAD(fd);
+
id=RFIFOL(fd,4);
memcpy(name, RFIFOP(fd,32), NAME_LENGTH);
@@ -885,7 +884,6 @@ int intif_parse_WisMessage(int fd)
int intif_parse_WisEnd(int fd)
{
struct map_session_data* sd;
- RFIFOHEAD(fd);
if (battle_config.etc_log)
ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
@@ -918,7 +916,6 @@ int mapif_parse_WisToGM(int fd)
char Wisp_name[NAME_LENGTH];
char mbuf[255];
char *message;
- RFIFOHEAD(fd);
mes_len = RFIFOW(fd,2) - 30;
message = (char *) (mes_len >= 255 ? (char *) aMallocA(mes_len) : mbuf);
@@ -943,7 +940,6 @@ int intif_parse_Registers(int fd)
struct map_session_data *sd;
struct global_reg *reg;
int *qty;
- RFIFOHEAD(fd);
if( (sd=map_id2sd(RFIFOL(fd,4)))==NULL)
return 1;
@@ -994,7 +990,6 @@ int intif_parse_LoadStorage(int fd)
{
struct storage *stor;
struct map_session_data *sd;
- RFIFOHEAD(fd);
sd=map_id2sd( RFIFOL(fd,4) );
if(sd==NULL){
@@ -1038,7 +1033,6 @@ int intif_parse_LoadStorage(int fd)
// 倉庫データ送信成功
int intif_parse_SaveStorage(int fd)
{
- RFIFOHEAD(fd);
if(battle_config.save_log)
ShowInfo("intif_savestorage: done %d %d\n",RFIFOL(fd,2),RFIFOB(fd,6) );
storage_storage_saved(RFIFOL(fd,2));
@@ -1050,7 +1044,7 @@ int intif_parse_LoadGuildStorage(int fd)
struct guild_storage *gstor;
struct map_session_data *sd;
int guild_id;
- RFIFOHEAD(fd);
+
guild_id = RFIFOL(fd,8);
if(guild_id <= 0)
return 1;
@@ -1093,7 +1087,6 @@ int intif_parse_LoadGuildStorage(int fd)
}
int intif_parse_SaveGuildStorage(int fd)
{
- RFIFOHEAD(fd);
if(battle_config.save_log) {
ShowInfo("intif_save_guild_storage: done %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOB(fd,10) );
}
@@ -1104,7 +1097,6 @@ int intif_parse_SaveGuildStorage(int fd)
// パーティ作成可否
int intif_parse_PartyCreated(int fd)
{
- RFIFOHEAD(fd);
if(battle_config.etc_log)
ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2));
party_created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15));
@@ -1113,7 +1105,6 @@ int intif_parse_PartyCreated(int fd)
// パーティ情報
int intif_parse_PartyInfo(int fd)
{
- RFIFOHEAD(fd);
if( RFIFOW(fd,2)==8){
if(battle_config.error_log)
ShowWarning("intif: party noinfo %d\n",RFIFOL(fd,4));
@@ -1132,7 +1123,6 @@ int intif_parse_PartyInfo(int fd)
// パーティ追加通知
int intif_parse_PartyMemberAdded(int fd)
{
- RFIFOHEAD(fd);
if(battle_config.etc_log)
ShowInfo("intif: party member added Party (%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
party_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14));
@@ -1141,14 +1131,12 @@ int intif_parse_PartyMemberAdded(int fd)
// パーティ設定変更通知
int intif_parse_PartyOptionChanged(int fd)
{
- RFIFOHEAD(fd);
party_optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14));
return 0;
}
// パーティ脱退通知
int intif_parse_PartyMemberLeaved(int fd)
{
- RFIFOHEAD(fd);
if(battle_config.etc_log)
ShowInfo("intif: party member leaved: Party(%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
party_member_leaved(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
@@ -1157,23 +1145,18 @@ int intif_parse_PartyMemberLeaved(int fd)
// パーティ解散通知
int intif_parse_PartyBroken(int fd)
{
- RFIFOHEAD(fd);
party_broken(RFIFOL(fd,2));
return 0;
}
// パーティ移動通知
int intif_parse_PartyMove(int fd)
{
- RFIFOHEAD(fd);
party_recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17));
return 0;
}
// パーティメッセージ
int intif_parse_PartyMessage(int fd)
{
- RFIFOHEAD(fd);
-// if(battle_config.etc_log)
-// printf("intif_parse_PartyMessage: %s\n",RFIFOP(fd,12));
party_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
return 0;
}
@@ -1181,15 +1164,13 @@ int intif_parse_PartyMessage(int fd)
// ギルド作成可否
int intif_parse_GuildCreated(int fd)
{
- RFIFOHEAD(fd);
guild_created(RFIFOL(fd,2),RFIFOL(fd,6));
return 0;
}
// ギルド情報
int intif_parse_GuildInfo(int fd)
{
- RFIFOHEAD(fd);
- if( RFIFOW(fd,2)==8){
+ if(RFIFOW(fd,2) == 8) {
if(battle_config.error_log)
ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4));
guild_recv_noinfo(RFIFOL(fd,4));
@@ -1208,7 +1189,6 @@ int intif_parse_GuildInfo(int fd)
// ギルドメンバ追加通知
int intif_parse_GuildMemberAdded(int fd)
{
- RFIFOHEAD(fd);
if(battle_config.etc_log)
ShowInfo("intif: guild member added %d %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
guild_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
@@ -1217,23 +1197,19 @@ int intif_parse_GuildMemberAdded(int fd)
// ギルドメンバ脱退/追放通知
int intif_parse_GuildMemberLeaved(int fd)
{
- RFIFOHEAD(fd);
- guild_member_leaved(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),
- (char *) RFIFOP(fd,55), (char *) RFIFOP(fd,15));
+ guild_member_leaved(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(char *)RFIFOP(fd,55),(char *)RFIFOP(fd,15));
return 0;
}
// ギルドメンバオンライン状態/Lv変更通知
int intif_parse_GuildMemberInfoShort(int fd)
{
- RFIFOHEAD(fd);
guild_recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17));
return 0;
}
// ギルド解散通知
int intif_parse_GuildBroken(int fd)
{
- RFIFOHEAD(fd);
guild_broken(RFIFOL(fd,2),RFIFOB(fd,6));
return 0;
}
@@ -1246,7 +1222,6 @@ int intif_parse_GuildBasicInfoChanged(int fd)
void *data;
struct guild *g;
short dw;
- RFIFOHEAD(fd);
type=RFIFOW(fd,8);
guild_id=RFIFOL(fd,4);
data=RFIFOP(fd,10);
@@ -1268,7 +1243,6 @@ int intif_parse_GuildMemberInfoChanged(int fd)
int type, guild_id, account_id, char_id, idx, dd;
void* data;
struct guild *g;
- RFIFOHEAD(fd);
type=RFIFOW(fd,16);
guild_id=RFIFOL(fd,4);
account_id=RFIFOL(fd,8);
@@ -1311,7 +1285,6 @@ int intif_parse_GuildMemberInfoChanged(int fd)
// ギルド役職変更通知
int intif_parse_GuildPosition(int fd)
{
- RFIFOHEAD(fd);
if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 ){
if(battle_config.error_log)
ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12);
@@ -1322,14 +1295,12 @@ int intif_parse_GuildPosition(int fd)
// ギルドスキル割り振り通知
int intif_parse_GuildSkillUp(int fd)
{
- RFIFOHEAD(fd);
guild_skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
return 0;
}
// ギルド同盟/敵対通知
int intif_parse_GuildAlliance(int fd)
{
- RFIFOHEAD(fd);
guild_allianceack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),
RFIFOB(fd,18),(char *) RFIFOP(fd,19),(char *) RFIFOP(fd,43));
return 0;
@@ -1337,56 +1308,47 @@ int intif_parse_GuildAlliance(int fd)
// ギルド告知変更通知
int intif_parse_GuildNotice(int fd)
{
- RFIFOHEAD(fd);
guild_notice_changed(RFIFOL(fd,2),(char *) RFIFOP(fd,6),(char *) RFIFOP(fd,66));
return 0;
}
// ギルドエンブレム変更通知
int intif_parse_GuildEmblem(int fd)
{
- RFIFOHEAD(fd);
guild_emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8), (char *)RFIFOP(fd,12));
return 0;
}
// ギルド会話受信
int intif_parse_GuildMessage(int fd)
{
- RFIFOHEAD(fd);
guild_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
return 0;
}
// ギルド城データ要求返信
int intif_parse_GuildCastleDataLoad(int fd)
{
- RFIFOHEAD(fd);
return guild_castledataloadack(RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5));
}
// ギルド城データ変更通知
int intif_parse_GuildCastleDataSave(int fd)
{
- RFIFOHEAD(fd);
return guild_castledatasaveack(RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5));
}
// ギルド城データ一括受信(初期化時)
int intif_parse_GuildCastleAllDataLoad(int fd)
{
- RFIFOHEAD(fd);
return guild_castlealldataload(RFIFOW(fd,2),(struct guild_castle *)RFIFOP(fd,4));
}
int intif_parse_GuildMasterChanged(int fd)
{
- RFIFOHEAD(fd);
return guild_gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
}
// pet
int intif_parse_CreatePet(int fd)
{
- RFIFOHEAD(fd);
pet_get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6));
-
return 0;
}
@@ -1394,7 +1356,6 @@ int intif_parse_RecvPetData(int fd)
{
struct s_pet p;
int len;
- RFIFOHEAD(fd);
len=RFIFOW(fd,2);
if(sizeof(struct s_pet)!=len-9) {
if(battle_config.etc_log)
@@ -1409,7 +1370,6 @@ int intif_parse_RecvPetData(int fd)
}
int intif_parse_SavePetOk(int fd)
{
- RFIFOHEAD(fd);
if(RFIFOB(fd,6) == 1) {
if(battle_config.error_log)
ShowError("pet data save failure\n");
@@ -1420,7 +1380,6 @@ int intif_parse_SavePetOk(int fd)
int intif_parse_DeletePetOk(int fd)
{
- RFIFOHEAD(fd);
if(RFIFOB(fd,2) == 1) {
if(battle_config.error_log)
ShowError("pet data delete failure\n");
@@ -1432,7 +1391,6 @@ int intif_parse_DeletePetOk(int fd)
int intif_parse_ChangeNameOk(int fd)
{
struct map_session_data *sd = NULL;
- RFIFOHEAD(fd);
if((sd=map_id2sd(RFIFOL(fd,2)))==NULL ||
sd->status.char_id != RFIFOL(fd,6))
return 0;
@@ -1456,7 +1414,6 @@ int intif_parse_ChangeNameOk(int fd)
int intif_parse_CreateHomunculus(int fd)
{
int len;
- RFIFOHEAD(fd);
len=RFIFOW(fd,2)-9;
if(sizeof(struct s_homunculus)!=len) {
if(battle_config.etc_log)
@@ -1471,7 +1428,6 @@ int intif_parse_RecvHomunculusData(int fd)
{
int len;
- RFIFOHEAD(fd);
len=RFIFOW(fd,2)-9;
if(sizeof(struct s_homunculus)!=len) {
@@ -1485,7 +1441,6 @@ int intif_parse_RecvHomunculusData(int fd)
int intif_parse_SaveHomunculusOk(int fd)
{
- RFIFOHEAD(fd);
if(RFIFOB(fd,6) != 1) {
if(battle_config.error_log)
ShowError("homunculus data save failure for account %d\n", RFIFOL(fd,2));
@@ -1495,7 +1450,6 @@ int intif_parse_SaveHomunculusOk(int fd)
int intif_parse_DeleteHomunculusOk(int fd)
{
- RFIFOHEAD(fd);
if(RFIFOB(fd,2) != 1) {
if(battle_config.error_log)
ShowError("Homunculus data delete failure\n");
@@ -1510,7 +1464,6 @@ int intif_parse_DeleteHomunculusOk(int fd)
int intif_parse(int fd)
{
int packet_len, cmd;
- RFIFOHEAD(fd);
cmd = RFIFOW(fd,0);
// パケットのID確認
if(cmd<0x3800 || cmd>=0x3800+(sizeof(packet_len_table)/sizeof(packet_len_table[0])) ||
diff --git a/src/map/irc.c b/src/map/irc.c
index 7e72b3ea4..e74b89efa 100644
--- a/src/map/irc.c
+++ b/src/map/irc.c
@@ -147,7 +147,6 @@ int irc_parse(int fd)
}
if(RFIFOREST(fd) > 0){
char *incoming_string=aMalloc(RFIFOREST(fd)*sizeof(char));
- RFIFOHEAD(fd);
memcpy(incoming_string,RFIFOP(fd,0),RFIFOREST(fd));
send_to_parser(fd,incoming_string,"\n");
RFIFOSKIP(fd,RFIFOREST(fd));
diff --git a/src/map/log.c b/src/map/log.c
index f6167247e..5ee1a2d83 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -14,12 +14,6 @@
#include "log.h"
#include "battle.h"
-#ifndef SQL_DEBUG
- #define mysql_query(_x, _y) mysql_real_query(_x, _y, strlen(_y)) //supports ' in names and runs faster [Kevin]
-#else
- #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-#endif
-
struct Log_Config log_config;
char timestring[255];
diff --git a/src/map/mail.c b/src/map/mail.c
index 71c9b8c89..65d6ed3f3 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -24,18 +24,6 @@
#include "pc.h"
#include "mail.h"
-#ifndef TXT_ONLY
- #ifndef SQL_DEBUG
-
- #define mysql_query(_x, _y) mysql_real_query(_x, _y, strlen(_y))
-
- #else
-
- #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-
- #endif
-#endif
-
int MAIL_CHECK_TIME = 120000;
int mail_timer;
//extern char *msg_table[1000]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
diff --git a/src/map/map.c b/src/map/map.c
index f59f9d148..5af776569 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -179,11 +179,9 @@ int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing m
*------------------------------------------*/
void map_setusers(int fd)
{
- RFIFOHEAD(fd);
- WFIFOHEAD(fd, 2);
-
map_users = RFIFOL(fd,2);
// send some answer
+ WFIFOHEAD(fd, 2);
WFIFOW(fd,0) = 0x2718;
WFIFOSET(fd,2);
}
diff --git a/src/map/pc.c b/src/map/pc.c
index 2990e655e..caa4b535c 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -7012,7 +7012,6 @@ int pc_autosave(int tid,unsigned int tick,int id,int data)
int pc_read_gm_account(int fd)
{
int i = 0;
- RFIFOHEAD(fd);
if (gm_account != NULL)
aFree(gm_account);
GM_num = 0;