- Removed the TURBO socket mechanism - it was in fact just using a variable to cache a few arithmetic operations (premature optimization)

- Since the fifohead mess is gone, fixed leftover bad code structuring

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@10599 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2007-05-21 18:40:29 +00:00
parent 4c65e3f2e4
commit 9e7eb8804f
23 changed files with 1386 additions and 1577 deletions

View File

@ -3,6 +3,10 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/05/21
* Since the fifohead mess is gone, fixed leftover bad code structuring
* Removed the TURBO socket mechanism - it was in fact just using a
variable to cache a few arithmetic operations (premature optimization)
2007/05/20
* Fixed Chase Walk having a deactivation cast time (should be instant)
* Changed status calc to allow value 0 stats; aegis allows

View File

@ -33,9 +33,6 @@ endif
# OPT += -DPACKETVER=8
# Makes map-wide script variables be saved to SQL instead of TXT files.
# OPT += -DMAPREGSQL
# Turbo is an alternate socket access implementation which should be faster.
# DO NOT ENABLE YET as it isn't quite ready for general usage.
# OPT += -DTURBO
# Enable the perl regular expression support for scripts
# OPT += -DPCRE_SUPPORT
# OPT += -DGCOLLECT

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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);

View File

@ -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 *);

View File

@ -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);

View File

@ -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;

View File

@ -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`)

View File

@ -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){

View File

@ -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;

View File

@ -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))

View File

@ -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;
}

View File

@ -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;
}
}
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);
{
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;
}
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;
}
}
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;
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);
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);
//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);
//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);
}
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));

View File

@ -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];

View File

@ -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);

View File

@ -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) {

View File

@ -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])) ||

View File

@ -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));

View File

@ -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];

View File

@ -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)

View File

@ -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);
}

View File

@ -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;