Cleaned up some parts of the code.
Removed obsolete script function 'hasitems'. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@10838 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
bd846b5d97
commit
1ed7f6c584
@ -3118,14 +3118,6 @@ not.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*hasitems(0)
|
||||
|
||||
This function will return 1 if the invoking character has anything at all in
|
||||
their inventory and 0 if they do not. Even though the argument is not used for
|
||||
anything, it is required.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*getequipisidentify(<equipment slot>)
|
||||
|
||||
This function will return 1 if an item in the specified equipment slot is
|
||||
|
@ -676,8 +676,8 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg
|
||||
p->int_ = tmp_int[16];
|
||||
p->dex = tmp_int[17];
|
||||
p->luk = tmp_int[18];
|
||||
p->status_point = tmp_int[19] > USHRT_MAX ? USHRT_MAX : tmp_int[19];
|
||||
p->skill_point = tmp_int[20] > USHRT_MAX ? USHRT_MAX : tmp_int[20];
|
||||
p->status_point = min(tmp_int[19], USHRT_MAX);
|
||||
p->skill_point = min(tmp_int[20], USHRT_MAX);
|
||||
p->option = tmp_int[21];
|
||||
p->karma = tmp_int[22];
|
||||
p->manner = tmp_int[23];
|
||||
@ -1032,13 +1032,13 @@ void mmo_char_sync(void)
|
||||
// Data save
|
||||
fp = lock_fopen(char_txt, &lock);
|
||||
if (fp == NULL) {
|
||||
ShowWarning("Server can't not save characters.\n");
|
||||
char_log("WARNING: Server can't not save characters." RETCODE);
|
||||
ShowWarning("Server cannot save characters.\n");
|
||||
char_log("WARNING: Server cannot save characters." RETCODE);
|
||||
} else {
|
||||
for(i = 0; i < char_num; i++) {
|
||||
// create only once the line, and save it in the 2 files (it's speeder than repeat twice the loop and create twice the line)
|
||||
mmo_char_tostr(line, &char_dat[id[i]].status, char_dat[id[i]].global, char_dat[id[i]].global_num); // use of sorted index
|
||||
fprintf(fp, "%s" RETCODE, line);
|
||||
fprintf(fp, "%s" RETCODE, line);
|
||||
}
|
||||
fprintf(fp, "%d\t%%newid%%" RETCODE, char_id_count);
|
||||
lock_fclose(fp, char_txt, &lock);
|
||||
@ -1057,7 +1057,7 @@ void mmo_char_sync(void)
|
||||
for(i = 0; i < char_num; i++) {
|
||||
// create only once the line, and save it in the 2 files (it's speeder than repeat twice the loop and create twice the line)
|
||||
mmo_char_tostr(line, &char_dat[id[i]].status,char_dat[id[i]].global, char_dat[id[i]].global_num); // use of sorted index
|
||||
fprintf(fp, "%s" RETCODE, line);
|
||||
fprintf(fp, "%s" RETCODE, line);
|
||||
}
|
||||
fprintf(fp, "%d\t%%newid%%" RETCODE, char_id_count);
|
||||
lock_fclose(fp, backup_txt, &lock);
|
||||
@ -1668,9 +1668,9 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
|
||||
return 0;
|
||||
|
||||
WBUFL(buf,0) = p->char_id;
|
||||
WBUFL(buf,4) = p->base_exp>LONG_MAX?LONG_MAX:p->base_exp;
|
||||
WBUFL(buf,4) = min(p->base_exp, LONG_MAX);
|
||||
WBUFL(buf,8) = p->zeny;
|
||||
WBUFL(buf,12) = p->job_exp>LONG_MAX?LONG_MAX:p->job_exp;
|
||||
WBUFL(buf,12) = min(p->job_exp, LONG_MAX);
|
||||
WBUFL(buf,16) = p->job_level;
|
||||
|
||||
WBUFL(buf,20) = 0;// probably opt1
|
||||
@ -1680,17 +1680,17 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
|
||||
WBUFL(buf,32) = p->karma;
|
||||
WBUFL(buf,36) = p->manner;
|
||||
|
||||
WBUFW(buf,40) = (p->status_point > SHRT_MAX) ? SHRT_MAX : p->status_point;
|
||||
WBUFW(buf,42) = (p->hp > SHRT_MAX) ? SHRT_MAX : p->hp;
|
||||
WBUFW(buf,44) = (p->max_hp > SHRT_MAX) ? SHRT_MAX : p->max_hp;
|
||||
WBUFW(buf,46) = (p->sp > SHRT_MAX) ? SHRT_MAX : p->sp;
|
||||
WBUFW(buf,48) = (p->max_sp > SHRT_MAX) ? SHRT_MAX : p->max_sp;
|
||||
WBUFW(buf,40) = min(p->status_point, SHRT_MAX);
|
||||
WBUFW(buf,42) = min(p->hp, SHRT_MAX);
|
||||
WBUFW(buf,44) = min(p->max_hp, SHRT_MAX);
|
||||
WBUFW(buf,46) = min(p->sp, SHRT_MAX);
|
||||
WBUFW(buf,48) = min(p->max_sp, SHRT_MAX);
|
||||
WBUFW(buf,50) = DEFAULT_WALK_SPEED; // p->speed;
|
||||
WBUFW(buf,52) = p->class_;
|
||||
WBUFW(buf,54) = p->hair;
|
||||
WBUFW(buf,56) = p->option&0x20 ? 0 : p->weapon; //When the weapon is sent and your option is riding, the client crashes on login!?
|
||||
WBUFW(buf,58) = p->base_level;
|
||||
WBUFW(buf,60) = (p->skill_point > SHRT_MAX) ? SHRT_MAX : p->skill_point;
|
||||
WBUFW(buf,60) = min(p->skill_point, SHRT_MAX);
|
||||
WBUFW(buf,62) = p->head_bottom;
|
||||
WBUFW(buf,64) = p->shield;
|
||||
WBUFW(buf,66) = p->head_top;
|
||||
@ -1700,12 +1700,12 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
|
||||
|
||||
memcpy(WBUFP(buf,74), p->name, NAME_LENGTH);
|
||||
|
||||
WBUFB(buf,98) = (p->str > UCHAR_MAX) ? UCHAR_MAX : p->str;
|
||||
WBUFB(buf,99) = (p->agi > UCHAR_MAX) ? UCHAR_MAX : p->agi;
|
||||
WBUFB(buf,100) = (p->vit > UCHAR_MAX) ? UCHAR_MAX : p->vit;
|
||||
WBUFB(buf,101) = (p->int_ > UCHAR_MAX) ? UCHAR_MAX : p->int_;
|
||||
WBUFB(buf,102) = (p->dex > UCHAR_MAX) ? UCHAR_MAX : p->dex;
|
||||
WBUFB(buf,103) = (p->luk > UCHAR_MAX) ? UCHAR_MAX : p->luk;
|
||||
WBUFB(buf,98) = min(p->str, UCHAR_MAX);
|
||||
WBUFB(buf,99) = min(p->agi, UCHAR_MAX);
|
||||
WBUFB(buf,100) = min(p->vit, UCHAR_MAX);
|
||||
WBUFB(buf,101) = min(p->int_, UCHAR_MAX);
|
||||
WBUFB(buf,102) = min(p->dex, UCHAR_MAX);
|
||||
WBUFB(buf,103) = min(p->luk, UCHAR_MAX);
|
||||
//Updated packet structure with rename-button included. Credits to Sara-chan
|
||||
#if PACKETVER > 7
|
||||
WBUFW(buf,104) = p->char_num;
|
||||
@ -1941,7 +1941,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
|
||||
|
||||
int send_accounts_tologin(int tid, unsigned int tick, int id, int data);
|
||||
|
||||
int parse_tologin(int fd)
|
||||
int parse_fromlogin(int fd)
|
||||
{
|
||||
int i;
|
||||
struct char_session_data *sd;
|
||||
@ -1962,7 +1962,7 @@ int parse_tologin(int fd)
|
||||
sd = (struct char_session_data*)session[fd]->session_data;
|
||||
|
||||
while(RFIFOREST(fd) >= 2) {
|
||||
// printf("parse_tologin: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
|
||||
// printf("parse_fromlogin: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
|
||||
|
||||
switch(RFIFOW(fd,0)) {
|
||||
case 0x2711:
|
||||
@ -2078,7 +2078,7 @@ int parse_tologin(int fd)
|
||||
WBUFL(buf,2) = RFIFOL(fd,2); // account
|
||||
WBUFL(buf,6) = RFIFOL(fd,6); // GM level
|
||||
mapif_sendall(buf,10);
|
||||
// printf("parse_tologin: To become GM answer: char -> map.\n");
|
||||
// printf("parse_fromlogin: To become GM answer: char -> map.\n");
|
||||
|
||||
RFIFOSKIP(fd,10);
|
||||
}
|
||||
@ -2941,8 +2941,8 @@ int parse_frommap(int fd)
|
||||
WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
|
||||
WFIFOW(map_fd,0) = 0x2afd;
|
||||
WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
|
||||
WFIFOL(map_fd,4) = RFIFOL(fd, 2); //Account ID
|
||||
WFIFOL(map_fd,8) = RFIFOL(fd, 6); //Login1
|
||||
WFIFOL(map_fd,4) = RFIFOL(fd,2); //Account ID
|
||||
WFIFOL(map_fd,8) = RFIFOL(fd,6); //Login1
|
||||
WFIFOL(map_fd,16) = RFIFOL(fd,10); //Login2
|
||||
WFIFOL(map_fd,12) = (unsigned long)0; //TODO: connect_until_time, how do I figure it out right now?
|
||||
memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
|
||||
@ -3255,20 +3255,23 @@ int parse_frommap(int fd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Searches for the mapserver that has a given map (and optionally ip/port, if not -1).
|
||||
// If found, returns the server's index in the 'server' array (otherwise returns -1).
|
||||
int search_mapserver(unsigned short map, uint32 ip, uint16 port)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for(i = 0; i < MAX_MAP_SERVERS; i++)
|
||||
if (server_fd[i] > 0)
|
||||
{
|
||||
if (server_fd[i] > 0
|
||||
&& (ip == (uint32)-1 || server[i].ip == ip)
|
||||
&& (port == (uint16)-1 || server[i].port == port))
|
||||
{
|
||||
for (j = 0; server[i].map[j]; j++)
|
||||
if (server[i].map[j] == map) {
|
||||
if (ip != (uint32)-1 && server[i].ip != ip)
|
||||
continue;
|
||||
if (port != (uint16)-1 && server[i].port != port)
|
||||
continue;
|
||||
if (server[i].map[j] == map)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -3442,8 +3445,7 @@ int parse_char(int fd)
|
||||
break;
|
||||
}
|
||||
cd = &char_dat[sd->found_char[ch]].status;
|
||||
char_log("Character Selected, Account ID: %d, Character Slot: %d, Character Name: %s." RETCODE,
|
||||
sd->account_id, char_num, cd->name);
|
||||
char_log("Character Selected, Account ID: %d, Character Slot: %d, Character Name: %s." RETCODE, sd->account_id, char_num, cd->name);
|
||||
|
||||
cd->sex = sd->sex;
|
||||
|
||||
@ -3926,7 +3928,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data)
|
||||
login_fd = 0;
|
||||
return 0;
|
||||
}
|
||||
session[login_fd]->func_parse = parse_tologin;
|
||||
session[login_fd]->func_parse = parse_fromlogin;
|
||||
realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
|
||||
|
||||
WFIFOHEAD(login_fd,86);
|
||||
@ -4332,8 +4334,6 @@ int do_init(int argc, char **argv)
|
||||
|
||||
set_defaultparse(parse_char);
|
||||
|
||||
char_fd = make_listen_bind(bind_ip, char_port);
|
||||
|
||||
add_timer_func_list(check_connect_login_server, "check_connect_login_server");
|
||||
add_timer_func_list(send_users_tologin, "send_users_tologin");
|
||||
add_timer_func_list(send_accounts_tologin, "send_accounts_tologin");
|
||||
@ -4354,6 +4354,8 @@ int do_init(int argc, char **argv)
|
||||
//##TODO invoke a CONSOLE_START plugin event
|
||||
}
|
||||
|
||||
char_fd = make_listen_bind(bind_ip, char_port);
|
||||
|
||||
char_log("The char-server is ready (Server is listening on the port %d)." RETCODE, char_port);
|
||||
|
||||
ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port);
|
||||
|
@ -743,27 +743,15 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){
|
||||
int memitemdata_to_sql(struct itemtmp mapitem[], int count, int char_id, int tableswitch)
|
||||
{
|
||||
int i,j, flag, id;
|
||||
char *tablename;
|
||||
char* tablename;
|
||||
char selectoption[16];
|
||||
char * str_p = tmp_sql;
|
||||
char* str_p = tmp_sql;
|
||||
|
||||
switch (tableswitch) {
|
||||
case TABLE_INVENTORY:
|
||||
tablename = inventory_db; // no need for sprintf here as *_db are char*.
|
||||
sprintf(selectoption,"char_id");
|
||||
break;
|
||||
case TABLE_CART:
|
||||
tablename = cart_db;
|
||||
sprintf(selectoption,"char_id");
|
||||
break;
|
||||
case TABLE_STORAGE:
|
||||
tablename = storage_db;
|
||||
sprintf(selectoption,"account_id");
|
||||
break;
|
||||
case TABLE_GUILD_STORAGE:
|
||||
tablename = guild_storage_db;
|
||||
sprintf(selectoption,"guild_id");
|
||||
break;
|
||||
case TABLE_INVENTORY: tablename = inventory_db; sprintf(selectoption,"char_id"); break;
|
||||
case TABLE_CART: tablename = cart_db; sprintf(selectoption,"char_id"); break;
|
||||
case TABLE_STORAGE: tablename = storage_db; sprintf(selectoption,"account_id"); break;
|
||||
case TABLE_GUILD_STORAGE: tablename = guild_storage_db; sprintf(selectoption,"guild_id"); break;
|
||||
default:
|
||||
ShowError("Invalid table name!\n");
|
||||
return 1;
|
||||
@ -1578,50 +1566,45 @@ int count_users(void)
|
||||
/// Writes char data to the buffer in the format used by the client.
|
||||
/// Used in packets 0x6b (chars info) and 0x6d (new char info)
|
||||
/// Returns the size (106 or 108)
|
||||
int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
|
||||
int mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p)
|
||||
{
|
||||
if( buf == NULL || p == NULL )
|
||||
return 0;
|
||||
|
||||
WBUFL(buf,0) = p->char_id;
|
||||
WBUFL(buf,4) = p->base_exp>LONG_MAX?LONG_MAX:p->base_exp;
|
||||
WBUFL(buf,4) = min(p->base_exp, LONG_MAX);
|
||||
WBUFL(buf,8) = p->zeny;
|
||||
WBUFL(buf,12) = p->job_exp>LONG_MAX?LONG_MAX:p->job_exp;
|
||||
WBUFL(buf,12) = min(p->job_exp, LONG_MAX);
|
||||
WBUFL(buf,16) = p->job_level;
|
||||
|
||||
WBUFL(buf,20) = 0;// probably opt1
|
||||
WBUFL(buf,24) = 0;// probably opt2
|
||||
WBUFL(buf,20) = 0; // probably opt1
|
||||
WBUFL(buf,24) = 0; // probably opt2
|
||||
WBUFL(buf,28) = p->option;
|
||||
|
||||
WBUFL(buf,32) = p->karma;
|
||||
WBUFL(buf,36) = p->manner;
|
||||
|
||||
WBUFW(buf,40) = (p->status_point > SHRT_MAX) ? SHRT_MAX : p->status_point;
|
||||
WBUFW(buf,42) = (p->hp > SHRT_MAX) ? SHRT_MAX : p->hp;
|
||||
WBUFW(buf,44) = (p->max_hp > SHRT_MAX) ? SHRT_MAX : p->max_hp;
|
||||
WBUFW(buf,46) = (p->sp > SHRT_MAX) ? SHRT_MAX : p->sp;
|
||||
WBUFW(buf,48) = (p->max_sp > SHRT_MAX) ? SHRT_MAX : p->max_sp;
|
||||
WBUFW(buf,40) = min(p->status_point, SHRT_MAX);
|
||||
WBUFW(buf,42) = min(p->hp, SHRT_MAX);
|
||||
WBUFW(buf,44) = min(p->max_hp, SHRT_MAX);
|
||||
WBUFW(buf,46) = min(p->sp, SHRT_MAX);
|
||||
WBUFW(buf,48) = min(p->max_sp, SHRT_MAX);
|
||||
WBUFW(buf,50) = DEFAULT_WALK_SPEED; // p->speed;
|
||||
WBUFW(buf,52) = p->class_;
|
||||
WBUFW(buf,54) = p->hair;
|
||||
WBUFW(buf,56) = p->option&0x20 ? 0 : p->weapon; //When the weapon is sent and your option is riding, the client crashes on login!?
|
||||
WBUFW(buf,58) = p->base_level;
|
||||
WBUFW(buf,60) = (p->skill_point > SHRT_MAX) ? SHRT_MAX : p->skill_point;
|
||||
WBUFW(buf,60) = min(p->skill_point, SHRT_MAX);
|
||||
WBUFW(buf,62) = p->head_bottom;
|
||||
WBUFW(buf,64) = p->shield;
|
||||
WBUFW(buf,66) = p->head_top;
|
||||
WBUFW(buf,68) = p->head_mid;
|
||||
WBUFW(buf,70) = p->hair_color;
|
||||
WBUFW(buf,72) = p->clothes_color;
|
||||
|
||||
memcpy(WBUFP(buf,74), p->name, NAME_LENGTH);
|
||||
|
||||
WBUFB(buf,98) = (p->str > UCHAR_MAX) ? UCHAR_MAX : p->str;
|
||||
WBUFB(buf,99) = (p->agi > UCHAR_MAX) ? UCHAR_MAX : p->agi;
|
||||
WBUFB(buf,100) = (p->vit > UCHAR_MAX) ? UCHAR_MAX : p->vit;
|
||||
WBUFB(buf,101) = (p->int_ > UCHAR_MAX) ? UCHAR_MAX : p->int_;
|
||||
WBUFB(buf,102) = (p->dex > UCHAR_MAX) ? UCHAR_MAX : p->dex;
|
||||
WBUFB(buf,103) = (p->luk > UCHAR_MAX) ? UCHAR_MAX : p->luk;
|
||||
WBUFB(buf,98) = min(p->str, UCHAR_MAX);
|
||||
WBUFB(buf,99) = min(p->agi, UCHAR_MAX);
|
||||
WBUFB(buf,100) = min(p->vit, UCHAR_MAX);
|
||||
WBUFB(buf,101) = min(p->int_, UCHAR_MAX);
|
||||
WBUFB(buf,102) = min(p->dex, UCHAR_MAX);
|
||||
WBUFB(buf,103) = min(p->luk, UCHAR_MAX);
|
||||
//Updated packet structure with rename-button included. Credits to Sara-chan
|
||||
#if PACKETVER > 7
|
||||
WBUFW(buf,104) = p->char_num;
|
||||
@ -1633,11 +1616,11 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
|
||||
#endif
|
||||
}
|
||||
|
||||
int mmo_char_send006b(int fd, struct char_session_data *sd)
|
||||
int mmo_char_send006b(int fd, struct char_session_data* sd)
|
||||
{
|
||||
int i, j, found_num = 0;
|
||||
|
||||
set_char_online(-1, 99,sd->account_id);
|
||||
set_char_online(-1, 99, sd->account_id);
|
||||
|
||||
//search char.
|
||||
sprintf(tmp_sql, "SELECT `char_id` FROM `%s` WHERE `account_id` = '%d' AND `char_num` < '%d'",char_db, sd->account_id, MAX_CHARS);
|
||||
@ -1664,19 +1647,17 @@ int mmo_char_send006b(int fd, struct char_session_data *sd)
|
||||
ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id);
|
||||
|
||||
|
||||
j = 24;// offset
|
||||
j = 24; // offset
|
||||
WFIFOHEAD(fd, j + found_num*108);
|
||||
WFIFOW(fd,0) = 0x6b;
|
||||
memset(WFIFOP(fd,4), 0, 20); // unknown bytes
|
||||
for(i = 0; i < found_num; i++)
|
||||
{
|
||||
WFIFOHEAD(fd, j + found_num*108);
|
||||
WFIFOW(fd,0) = 0x6b;
|
||||
memset(WFIFOP(fd,4), 0, 20);// unknown bytes
|
||||
for(i = 0; i < found_num; i++)
|
||||
{
|
||||
mmo_char_fromsql(sd->found_char[i], &char_dat, false);
|
||||
j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat);
|
||||
}
|
||||
WFIFOW(fd,2) = j;// packet len
|
||||
WFIFOSET(fd,j);
|
||||
mmo_char_fromsql(sd->found_char[i], &char_dat, false);
|
||||
j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat);
|
||||
}
|
||||
WFIFOW(fd,2) = j; // packet len
|
||||
WFIFOSET(fd,j);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1728,7 +1709,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
|
||||
|
||||
int send_accounts_tologin(int tid, unsigned int tick, int id, int data);
|
||||
|
||||
int parse_tologin(int fd)
|
||||
int parse_fromlogin(int fd)
|
||||
{
|
||||
int i;
|
||||
struct char_session_data *sd;
|
||||
@ -1749,8 +1730,9 @@ int parse_tologin(int fd)
|
||||
|
||||
// hehe. no need to set user limit on SQL version. :P
|
||||
// but char limitation is good way to maintain server. :D
|
||||
while(RFIFOREST(fd) >= 2) {
|
||||
// printf("parse_tologin : %d %d %x\n", fd, RFIFOREST(fd), RFIFOW(fd, 0));
|
||||
while(RFIFOREST(fd) >= 2)
|
||||
{
|
||||
// printf("parse_fromlogin : %d %d %x\n", fd, RFIFOREST(fd), RFIFOW(fd, 0));
|
||||
|
||||
switch(RFIFOW(fd,0)) {
|
||||
case 0x2711:
|
||||
@ -2608,13 +2590,11 @@ int parse_frommap(int fd)
|
||||
if (RFIFOREST(fd) < 35)
|
||||
return 0;
|
||||
{
|
||||
unsigned short name;
|
||||
int map_id, map_fd = -1;
|
||||
struct online_char_data* data;
|
||||
struct mmo_charstatus* char_data;
|
||||
|
||||
name = RFIFOW(fd,18);
|
||||
map_id = search_mapserver(name, ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
|
||||
map_id = search_mapserver(RFIFOW(fd,18), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
|
||||
if (map_id >= 0)
|
||||
map_fd = server_fd[map_id];
|
||||
//Char should just had been saved before this packet, so this should be safe. [Skotlex]
|
||||
@ -2975,20 +2955,23 @@ int parse_frommap(int fd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Searches for the mapserver that has a given map (and optionally ip/port, if not -1).
|
||||
// If found, returns the server's index in the 'server' array (otherwise returns -1).
|
||||
int search_mapserver(unsigned short map, uint32 ip, uint16 port)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
||||
for(i = 0; i < MAX_MAP_SERVERS; i++)
|
||||
if (server_fd[i] > 0)
|
||||
{
|
||||
if (server_fd[i] > 0
|
||||
&& (ip == (uint32)-1 || server[i].ip == ip)
|
||||
&& (port == (uint16)-1 || server[i].port == port))
|
||||
{
|
||||
for (j = 0; server[i].map[j]; j++)
|
||||
if (server[i].map[j] == map) {
|
||||
if (ip != (uint32)-1 && server[i].ip != ip)
|
||||
continue;
|
||||
if (port != (uint16)-1 && server[i].port != port)
|
||||
continue;
|
||||
if (server[i].map[j] == map)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -3615,7 +3598,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data)
|
||||
login_fd = 0;
|
||||
return 0;
|
||||
}
|
||||
session[login_fd]->func_parse = parse_tologin;
|
||||
session[login_fd]->func_parse = parse_fromlogin;
|
||||
realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
|
||||
|
||||
WFIFOHEAD(login_fd,86);
|
||||
@ -3705,16 +3688,16 @@ int char_lan_config_read(const char *lancfgName)
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
|
||||
void sql_config_read(const char *cfgName)
|
||||
void sql_config_read(const char* cfgName)
|
||||
{
|
||||
char line[1024], w1[1024], w2[1024];
|
||||
FILE *fp;
|
||||
FILE* fp;
|
||||
|
||||
ShowInfo("Reading file %s...\n", cfgName);
|
||||
|
||||
if ((fp = fopen(cfgName, "r")) == NULL) {
|
||||
ShowFatalError("file not found: %s\n", cfgName);
|
||||
exit(1);
|
||||
ShowError("file not found: %s\n", cfgName);
|
||||
return;
|
||||
}
|
||||
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
@ -3725,96 +3708,93 @@ void sql_config_read(const char *cfgName)
|
||||
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
|
||||
continue;
|
||||
|
||||
if(strcmpi(w1,"char_db")==0){
|
||||
if(!strcmpi(w1,"char_db"))
|
||||
strcpy(char_db,w2);
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
} else if(strcmpi(w1, "gm_read_method") == 0) {
|
||||
if(atoi(w2) != 0)
|
||||
char_gm_read = true;
|
||||
else
|
||||
char_gm_read = false;
|
||||
else if(!strcmpi(w1,"gm_read_method"))
|
||||
char_gm_read = config_switch(w2);
|
||||
//custom columns for login database
|
||||
}else if(strcmpi(w1,"login_db")==0){
|
||||
strcpy(login_db, w2);
|
||||
}else if(strcmpi(w1,"login_db_level")==0){
|
||||
else if(!strcmpi(w1,"login_db"))
|
||||
strcpy(login_db,w2);
|
||||
else if(!strcmpi(w1,"login_db_level"))
|
||||
strcpy(login_db_level,w2);
|
||||
}else if(strcmpi(w1,"login_db_account_id")==0){
|
||||
else if(!strcmpi(w1,"login_db_account_id"))
|
||||
strcpy(login_db_account_id,w2);
|
||||
}else if(strcmpi(w1,"lowest_gm_level")==0){
|
||||
else if(!strcmpi(w1,"lowest_gm_level")) {
|
||||
lowest_gm_level = atoi(w2);
|
||||
ShowStatus("set lowest_gm_level : %s\n",w2);
|
||||
ShowStatus("set lowest_gm_level : %s\n", w2);
|
||||
}
|
||||
#endif
|
||||
}else if(strcmpi(w1,"scdata_db")==0){
|
||||
else if(!strcmpi(w1,"scdata_db"))
|
||||
strcpy(scdata_db,w2);
|
||||
}else if(strcmpi(w1,"cart_db")==0){
|
||||
else if(!strcmpi(w1,"cart_db"))
|
||||
strcpy(cart_db,w2);
|
||||
}else if(strcmpi(w1,"inventory_db")==0){
|
||||
strcpy(inventory_db,w2);
|
||||
}else if(strcmpi(w1,"charlog_db")==0){
|
||||
else if(!strcmpi(w1,"inventory_db"))
|
||||
strcpy(inventory_db, w2);
|
||||
else if(!strcmpi(w1,"charlog_db"))
|
||||
strcpy(charlog_db,w2);
|
||||
}else if(strcmpi(w1,"storage_db")==0){
|
||||
else if(!strcmpi(w1,"storage_db"))
|
||||
strcpy(storage_db,w2);
|
||||
}else if(strcmpi(w1,"reg_db")==0){
|
||||
else if(!strcmpi(w1,"reg_db"))
|
||||
strcpy(reg_db,w2);
|
||||
}else if(strcmpi(w1,"skill_db")==0){
|
||||
else if(!strcmpi(w1,"skill_db"))
|
||||
strcpy(skill_db,w2);
|
||||
}else if(strcmpi(w1,"interlog_db")==0){
|
||||
else if(!strcmpi(w1,"interlog_db"))
|
||||
strcpy(interlog_db,w2);
|
||||
}else if(strcmpi(w1,"memo_db")==0){
|
||||
else if(!strcmpi(w1,"memo_db"))
|
||||
strcpy(memo_db,w2);
|
||||
}else if(strcmpi(w1,"guild_db")==0){
|
||||
else if(!strcmpi(w1,"guild_db"))
|
||||
strcpy(guild_db,w2);
|
||||
}else if(strcmpi(w1,"guild_alliance_db")==0){
|
||||
else if(!strcmpi(w1,"guild_alliance_db"))
|
||||
strcpy(guild_alliance_db,w2);
|
||||
}else if(strcmpi(w1,"guild_castle_db")==0){
|
||||
else if(!strcmpi(w1,"guild_castle_db"))
|
||||
strcpy(guild_castle_db,w2);
|
||||
}else if(strcmpi(w1,"guild_expulsion_db")==0){
|
||||
else if(!strcmpi(w1,"guild_expulsion_db"))
|
||||
strcpy(guild_expulsion_db,w2);
|
||||
}else if(strcmpi(w1,"guild_member_db")==0){
|
||||
else if(!strcmpi(w1,"guild_member_db"))
|
||||
strcpy(guild_member_db,w2);
|
||||
}else if(strcmpi(w1,"guild_skill_db")==0){
|
||||
else if(!strcmpi(w1,"guild_skill_db"))
|
||||
strcpy(guild_skill_db,w2);
|
||||
}else if(strcmpi(w1,"guild_position_db")==0){
|
||||
else if(!strcmpi(w1,"guild_position_db"))
|
||||
strcpy(guild_position_db,w2);
|
||||
}else if(strcmpi(w1,"guild_storage_db")==0){
|
||||
else if(!strcmpi(w1,"guild_storage_db"))
|
||||
strcpy(guild_storage_db,w2);
|
||||
}else if(strcmpi(w1,"party_db")==0){
|
||||
else if(!strcmpi(w1,"party_db"))
|
||||
strcpy(party_db,w2);
|
||||
}else if(strcmpi(w1,"pet_db")==0){
|
||||
else if(!strcmpi(w1,"pet_db"))
|
||||
strcpy(pet_db,w2);
|
||||
}else if(strcmpi(w1,"friend_db")==0){
|
||||
else if(!strcmpi(w1,"friend_db"))
|
||||
strcpy(friend_db,w2);
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
}else if(strcmpi(w1,"db_path")==0){
|
||||
else if(!strcmpi(w1,"db_path"))
|
||||
strcpy(db_path,w2);
|
||||
//Map server option to use SQL db or not
|
||||
}else if(strcmpi(w1,"use_sql_db")==0){ // added for sql item_db read for char server [Valaris]
|
||||
//Map server option to use SQL item/mob-db or not
|
||||
else if(!strcmpi(w1,"use_sql_db")==0){
|
||||
db_use_sqldbs = config_switch(w2);
|
||||
ShowStatus("Using SQL dbs: %s\n",w2);
|
||||
}else if(strcmpi(w1,"item_db_db")==0){
|
||||
}
|
||||
else if(!strcmpi(w1,"item_db_db"))
|
||||
strcpy(item_db_db,w2);
|
||||
}else if(strcmpi(w1,"item_db2_db")==0){
|
||||
else if(!strcmpi(w1,"item_db2_db"))
|
||||
strcpy(item_db2_db,w2);
|
||||
#endif
|
||||
//support the import command, just like any other config
|
||||
}else if(strcmpi(w1,"import")==0){
|
||||
else if(!strcmpi(w1,"import"))
|
||||
sql_config_read(w2);
|
||||
}
|
||||
|
||||
}
|
||||
fclose(fp);
|
||||
ShowInfo("Done reading %s.\n", cfgName);
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
|
||||
int char_config_read(const char *cfgName)
|
||||
int char_config_read(const char* cfgName)
|
||||
{
|
||||
char line[1024], w1[1024], w2[1024];
|
||||
FILE* fp = fopen(cfgName, "r");
|
||||
|
||||
if (fp == NULL) {
|
||||
ShowFatalError("Configuration file not found: %s.\n", cfgName);
|
||||
exit(1);
|
||||
ShowError("Configuration file not found: %s.\n", cfgName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ShowInfo("Reading configuration file %s...\n", cfgName);
|
||||
@ -3968,7 +3948,6 @@ int char_config_read(const char *cfgName)
|
||||
void do_final(void)
|
||||
{
|
||||
ShowInfo("Doing final stage...\n");
|
||||
//inter_save();
|
||||
do_final_itemdb();
|
||||
//check SQL save progress.
|
||||
//wait until save char complete
|
||||
@ -4074,11 +4053,8 @@ int do_init(int argc, char **argv)
|
||||
mmo_char_sql_init();
|
||||
ShowInfo("char server initialized.\n");
|
||||
|
||||
// ShowDebug("set parser -> parse_char()...\n");
|
||||
set_defaultparse(parse_char);
|
||||
|
||||
// ShowDebug("set terminate function -> do_final().....\n");
|
||||
|
||||
if ((naddr_ != 0) && (!login_ip || !char_ip))
|
||||
{
|
||||
char ip_str[16];
|
||||
@ -4124,32 +4100,32 @@ int do_init(int argc, char **argv)
|
||||
{
|
||||
//##TODO invoke a CONSOLE_START plugin event
|
||||
}
|
||||
|
||||
|
||||
//Cleaning the tables for NULL entrys @ startup [Sirius]
|
||||
//Chardb clean
|
||||
ShowInfo("Cleaning the '%s' table...\n", char_db);
|
||||
sprintf(tmp_sql,"DELETE FROM `%s` WHERE `account_id` = '0'", char_db);
|
||||
if(mysql_query(&mysql_handle, tmp_sql)){
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
|
||||
//guilddb clean
|
||||
ShowInfo("Cleaning the '%s' table...\n", guild_db);
|
||||
sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db);
|
||||
if(mysql_query(&mysql_handle, tmp_sql)){
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
|
||||
//guildmemberdb clean
|
||||
ShowInfo("Cleaning the '%s' table...\n", guild_member_db);
|
||||
sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db);
|
||||
if(mysql_query(&mysql_handle, tmp_sql)){
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
|
||||
//Chardb clean
|
||||
ShowInfo("Cleaning the '%s' table...\n", char_db);
|
||||
sprintf(tmp_sql,"DELETE FROM `%s` WHERE `account_id` = '0'", char_db);
|
||||
if(mysql_query(&mysql_handle, tmp_sql)){
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
|
||||
//guilddb clean
|
||||
ShowInfo("Cleaning the '%s' table...\n", guild_db);
|
||||
sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db);
|
||||
if(mysql_query(&mysql_handle, tmp_sql)){
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
|
||||
//guildmemberdb clean
|
||||
ShowInfo("Cleaning the '%s' table...\n", guild_member_db);
|
||||
sprintf(tmp_sql,"DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db);
|
||||
if(mysql_query(&mysql_handle, tmp_sql)){
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
|
||||
ShowInfo("End of char server initilization function.\n");
|
||||
ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port);
|
||||
return 0;
|
||||
@ -4157,47 +4133,47 @@ int do_init(int argc, char **argv)
|
||||
|
||||
int char_child(int parent_id, int child_id)
|
||||
{
|
||||
int tmp_id = 0;
|
||||
sprintf (tmp_sql, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id);
|
||||
if (mysql_query (&mysql_handle, tmp_sql)) {
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
sql_res = mysql_store_result (&mysql_handle);
|
||||
sql_row = sql_res?mysql_fetch_row (sql_res):NULL;
|
||||
if (sql_row)
|
||||
tmp_id = atoi (sql_row[0]);
|
||||
else
|
||||
ShowError("CHAR: child Failed!\n");
|
||||
if (sql_res) mysql_free_result (sql_res);
|
||||
if ( tmp_id == child_id )
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
int tmp_id = 0;
|
||||
sprintf (tmp_sql, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id);
|
||||
if (mysql_query (&mysql_handle, tmp_sql)) {
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
sql_res = mysql_store_result (&mysql_handle);
|
||||
sql_row = sql_res?mysql_fetch_row (sql_res):NULL;
|
||||
if (sql_row)
|
||||
tmp_id = atoi (sql_row[0]);
|
||||
else
|
||||
ShowError("CHAR: child Failed!\n");
|
||||
if (sql_res) mysql_free_result (sql_res);
|
||||
if ( tmp_id == child_id )
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int char_married(int pl1,int pl2)
|
||||
int char_married(int pl1, int pl2)
|
||||
{
|
||||
int tmp_id = 0;
|
||||
sprintf (tmp_sql, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1);
|
||||
if (mysql_query (&mysql_handle, tmp_sql)) {
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
sql_res = mysql_store_result (&mysql_handle);
|
||||
sql_row = sql_res?mysql_fetch_row (sql_res):NULL;
|
||||
if (sql_row)
|
||||
tmp_id = atoi (sql_row[0]);
|
||||
else
|
||||
ShowError("CHAR: married Failed!\n");
|
||||
if (sql_res) mysql_free_result (sql_res);
|
||||
if ( tmp_id == pl2 )
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
int tmp_id = 0;
|
||||
sprintf (tmp_sql, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1);
|
||||
if (mysql_query (&mysql_handle, tmp_sql)) {
|
||||
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
|
||||
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
|
||||
}
|
||||
sql_res = mysql_store_result (&mysql_handle);
|
||||
sql_row = sql_res?mysql_fetch_row (sql_res):NULL;
|
||||
if (sql_row)
|
||||
tmp_id = atoi (sql_row[0]);
|
||||
else
|
||||
ShowError("CHAR: married Failed!\n");
|
||||
if (sql_res) mysql_free_result (sql_res);
|
||||
if ( tmp_id == pl2 )
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int char_family(int pl1,int pl2,int pl3)
|
||||
int char_family(int pl1, int pl2, int pl3)
|
||||
{
|
||||
int charid, partnerid, childid;
|
||||
sprintf (tmp_sql, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, pl1, pl2, pl3);
|
||||
|
@ -51,29 +51,29 @@ char main_chat_nick[16] = "Main";
|
||||
|
||||
// sending packet list
|
||||
// NOTE: This variable ain't used at all! And it's confusing.. where do I add that the length of packet 0x2b07 is 10? x.x [Skotlex]
|
||||
int inter_send_packet_length[]={
|
||||
-1,-1,27,-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
-1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0,
|
||||
35,-1,11,15, 34,29, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1,
|
||||
9, 9,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
11,-1, 7, 3, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
int inter_send_packet_length[] = {
|
||||
-1,-1,27,-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3800-
|
||||
-1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, // 3810-
|
||||
35,-1,11,15, 34,29, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, // 3820-
|
||||
10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, // 3830-
|
||||
9, 9,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3840-
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3850-
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3860-
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3870-
|
||||
11,-1, 7, 3, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3880-
|
||||
};
|
||||
// recv. packet list
|
||||
int inter_recv_packet_length[]={
|
||||
-1,-1, 7,-1, -1,13,36, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3000-0x300f
|
||||
6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, //0x3010-0x301f
|
||||
-1, 6,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, //0x3020-0x302f
|
||||
-1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 14,19,186,-1, //0x3030-0x303f
|
||||
5, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3080-0x308f
|
||||
-1,10,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x3090 - 0x309f Homunculus packets [albator]
|
||||
int inter_recv_packet_length[] = {
|
||||
-1,-1, 7,-1, -1,13,36, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3000-
|
||||
6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010-
|
||||
-1, 6,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020-
|
||||
-1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 14,19,186,-1, // 3030-
|
||||
5, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3040-
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050-
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060-
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070-
|
||||
48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3080-
|
||||
-1,10,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator]
|
||||
};
|
||||
|
||||
struct WisData {
|
||||
@ -187,86 +187,83 @@ int inter_accreg_sql_init(void)
|
||||
/*==========================================
|
||||
* read config file
|
||||
*------------------------------------------*/
|
||||
static int inter_config_read(const char *cfgName)
|
||||
static int inter_config_read(const char* cfgName)
|
||||
{
|
||||
int i;
|
||||
char line[1024], w1[1024], w2[1024];
|
||||
FILE *fp;
|
||||
FILE* fp;
|
||||
|
||||
fp=fopen(cfgName,"r");
|
||||
if(fp==NULL){
|
||||
fp = fopen(cfgName, "r");
|
||||
if(fp == NULL) {
|
||||
ShowError("file not found: %s\n", cfgName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ShowInfo("reading file %s...\n",cfgName);
|
||||
ShowInfo("reading file %s...\n", cfgName);
|
||||
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2);
|
||||
if(i!=2)
|
||||
i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2);
|
||||
if(i != 2)
|
||||
continue;
|
||||
|
||||
if(strcmpi(w1,"char_server_ip")==0){
|
||||
strcpy(char_server_ip, w2);
|
||||
ShowStatus ("set char_server_ip : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"char_server_port")==0){
|
||||
char_server_port=atoi(w2);
|
||||
ShowStatus ("set char_server_port : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"char_server_id")==0){
|
||||
strcpy(char_server_id, w2);
|
||||
ShowStatus ("set char_server_id : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"char_server_pw")==0){
|
||||
strcpy(char_server_pw, w2);
|
||||
ShowStatus ("set char_server_pw : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"char_server_db")==0){
|
||||
strcpy(char_server_db, w2);
|
||||
ShowStatus ("set char_server_db : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"default_codepage")==0){
|
||||
strcpy(default_codepage, w2);
|
||||
ShowStatus ("set default_codepage : %s\n",w2);
|
||||
if(!strcmpi(w1,"char_server_ip")) {
|
||||
strcpy(char_server_ip,w2);
|
||||
ShowStatus ("set char_server_ip : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_port")) {
|
||||
char_server_port = atoi(w2);
|
||||
ShowStatus ("set char_server_port : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_id")) {
|
||||
strcpy(char_server_id,w2);
|
||||
ShowStatus ("set char_server_id : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_pw")) {
|
||||
strcpy(char_server_pw,w2);
|
||||
ShowStatus ("set char_server_pw : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_db")) {
|
||||
strcpy(char_server_db,w2);
|
||||
ShowStatus ("set char_server_db : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"default_codepage")) {
|
||||
strcpy(default_codepage,w2);
|
||||
ShowStatus ("set default_codepage : %s\n", w2);
|
||||
}
|
||||
//Logins information to be read from the inter_athena.conf
|
||||
//for character deletion (checks email in the loginDB)
|
||||
else if(strcmpi(w1,"login_server_ip")==0){
|
||||
else
|
||||
if(!strcmpi(w1,"login_server_ip")) {
|
||||
strcpy(login_server_ip, w2);
|
||||
ShowStatus ("set login_server_ip : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"login_server_port")==0){
|
||||
login_server_port=atoi(w2);
|
||||
ShowStatus ("set login_server_port : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"login_server_id")==0){
|
||||
ShowStatus ("set login_server_ip : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"login_server_port")) {
|
||||
login_server_port = atoi(w2);
|
||||
ShowStatus ("set login_server_port : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"login_server_id")) {
|
||||
strcpy(login_server_id, w2);
|
||||
ShowStatus ("set login_server_id : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"login_server_pw")==0){
|
||||
ShowStatus ("set login_server_id : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"login_server_pw")) {
|
||||
strcpy(login_server_pw, w2);
|
||||
ShowStatus ("set login_server_pw : %s\n",w2);
|
||||
}
|
||||
else if(strcmpi(w1,"login_server_db")==0){
|
||||
ShowStatus ("set login_server_pw : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"login_server_db")) {
|
||||
strcpy(login_server_db, w2);
|
||||
ShowStatus ("set login_server_db : %s\n",w2);
|
||||
ShowStatus ("set login_server_db : %s\n", w2);
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
else if(strcmpi(w1,"party_share_level")==0){
|
||||
party_share_level=(unsigned int)atof(w2);
|
||||
}
|
||||
else if(strcmpi(w1,"log_inter")==0){
|
||||
else if(!strcmpi(w1,"party_share_level"))
|
||||
party_share_level = atoi(w2);
|
||||
else if(!strcmpi(w1,"log_inter"))
|
||||
log_inter = atoi(w2);
|
||||
}
|
||||
else if(strcmpi(w1, "main_chat_nick")==0){ // Main chat nick [LuzZza]
|
||||
strcpy(main_chat_nick, w2); //
|
||||
}
|
||||
else if(!strcmpi(w1,"main_chat_nick"))
|
||||
strcpy(main_chat_nick, w2);
|
||||
#endif //TXT_SQL_CONVERT
|
||||
else if(strcmpi(w1,"import")==0){
|
||||
else if(!strcmpi(w1,"import"))
|
||||
inter_config_read(w2);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
@ -277,7 +274,7 @@ static int inter_config_read(const char *cfgName)
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
|
||||
// Save interlog into sql
|
||||
int inter_log(char *fmt,...)
|
||||
int inter_log(char* fmt, ...)
|
||||
{
|
||||
char str[255];
|
||||
char temp_str[510]; //Needs be twice as long as str[] //Skotlex
|
||||
@ -438,7 +435,8 @@ int inter_sql_test (void)
|
||||
}
|
||||
|
||||
// finalize
|
||||
void inter_final(void) {
|
||||
void inter_final(void)
|
||||
{
|
||||
wis_db->destroy(wis_db, NULL);
|
||||
|
||||
inter_guild_sql_final();
|
||||
@ -451,7 +449,8 @@ void inter_final(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
int inter_mapif_init(int fd) {
|
||||
int inter_mapif_init(int fd)
|
||||
{
|
||||
inter_guild_mapif_init(fd);
|
||||
|
||||
return 0;
|
||||
@ -461,20 +460,22 @@ int inter_mapif_init(int fd) {
|
||||
//--------------------------------------------------------
|
||||
|
||||
// GM message sending
|
||||
int mapif_GMmessage(unsigned char *mes, int len, unsigned long color, int sfd) {
|
||||
int mapif_GMmessage(unsigned char *mes, int len, unsigned long color, int sfd)
|
||||
{
|
||||
unsigned char buf[2048];
|
||||
|
||||
if (len > 2048) len = 2047; //Make it fit to avoid crashes. [Skotlex]
|
||||
WBUFW(buf, 0) = 0x3800;
|
||||
WBUFW(buf, 2) = len;
|
||||
WBUFL(buf, 4) = color;
|
||||
memcpy(WBUFP(buf, 8), mes, len-8);
|
||||
WBUFW(buf,0) = 0x3800;
|
||||
WBUFW(buf,2) = len;
|
||||
WBUFL(buf,4) = color;
|
||||
memcpy(WBUFP(buf,8), mes, len - 8);
|
||||
mapif_sendallwos(sfd, buf, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Wis sending
|
||||
int mapif_wis_message(struct WisData *wd) {
|
||||
int mapif_wis_message(struct WisData *wd)
|
||||
{
|
||||
unsigned char buf[2048];
|
||||
if (wd->len > 2047-56) wd->len = 2047-56; //Force it to fit to avoid crashes. [Skotlex]
|
||||
|
||||
@ -549,11 +550,11 @@ int mapif_send_gmaccounts()
|
||||
WBUFW(buf,0) = 0x2b15;
|
||||
|
||||
for(i = 0; i < GM_num; i++) {
|
||||
WBUFL(buf, len) = gm_account[i].account_id;
|
||||
WBUFB(buf, len+4) = (unsigned char)gm_account[i].level;
|
||||
WBUFL(buf,len) = gm_account[i].account_id;
|
||||
WBUFB(buf,len+4) = (uint8)gm_account[i].level;
|
||||
len += 5;
|
||||
}
|
||||
WBUFW(buf, 2) = len;
|
||||
WBUFW(buf,2) = len;
|
||||
mapif_sendall(buf, len);
|
||||
|
||||
return 0;
|
||||
@ -588,7 +589,8 @@ int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason)
|
||||
//--------------------------------------------------------
|
||||
|
||||
// Existence check of WISP data
|
||||
int check_ttl_wisdata_sub(DBKey key, void *data, va_list ap) {
|
||||
int check_ttl_wisdata_sub(DBKey key, void *data, va_list ap)
|
||||
{
|
||||
unsigned long tick;
|
||||
struct WisData *wd = (struct WisData *)data;
|
||||
tick = va_arg(ap, unsigned long);
|
||||
@ -599,7 +601,8 @@ int check_ttl_wisdata_sub(DBKey key, void *data, va_list ap) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int check_ttl_wisdata(void) {
|
||||
int check_ttl_wisdata(void)
|
||||
{
|
||||
unsigned long tick = gettick();
|
||||
int i;
|
||||
|
||||
@ -623,18 +626,18 @@ int check_ttl_wisdata(void) {
|
||||
// GM message sending
|
||||
int mapif_parse_GMmessage(int fd)
|
||||
{
|
||||
RFIFOHEAD(fd);
|
||||
mapif_GMmessage(RFIFOP(fd, 8), RFIFOW(fd, 2), RFIFOL(fd, 4), fd);
|
||||
mapif_GMmessage(RFIFOP(fd,8), RFIFOW(fd,2), RFIFOL(fd,4), fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Wisp/page request to send
|
||||
int mapif_parse_WisRequest(int fd) {
|
||||
int mapif_parse_WisRequest(int fd)
|
||||
{
|
||||
struct WisData* wd;
|
||||
static int wisid = 0;
|
||||
char name[NAME_LENGTH], t_name[NAME_LENGTH*2]; //Needs space to allocate names with escaped chars [Skotlex]
|
||||
RFIFOHEAD(fd);
|
||||
|
||||
if ( fd <= 0 ) {return 0;} // check if we have a valid fd
|
||||
|
||||
if (RFIFOW(fd,2)-52 >= sizeof(wd->msg)) {
|
||||
@ -676,7 +679,7 @@ int mapif_parse_WisRequest(int fd) {
|
||||
mapif_send(fd, buf, 27);
|
||||
} else {
|
||||
|
||||
CREATE(wd, struct WisData, 1);
|
||||
CREATE(wd, struct WisData, 1);
|
||||
|
||||
// Whether the failure of previous wisp/page transmission (timeout)
|
||||
check_ttl_wisdata();
|
||||
@ -703,10 +706,11 @@ int mapif_parse_WisRequest(int fd) {
|
||||
|
||||
|
||||
// Wisp/page transmission result
|
||||
int mapif_parse_WisReply(int fd) {
|
||||
int mapif_parse_WisReply(int fd)
|
||||
{
|
||||
int id, flag;
|
||||
struct WisData *wd;
|
||||
RFIFOHEAD(fd);
|
||||
|
||||
id = RFIFOL(fd,2);
|
||||
flag = RFIFOB(fd,6);
|
||||
wd = idb_get(wis_db, id);
|
||||
@ -722,9 +726,10 @@ int mapif_parse_WisReply(int fd) {
|
||||
}
|
||||
|
||||
// Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers)
|
||||
int mapif_parse_WisToGM(int fd) {
|
||||
int mapif_parse_WisToGM(int fd)
|
||||
{
|
||||
unsigned char buf[2048]; // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
|
||||
RFIFOHEAD(fd);
|
||||
|
||||
ShowDebug("Sent packet back!\n");
|
||||
memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2));
|
||||
WBUFW(buf, 0) = 0x3803;
|
||||
@ -738,7 +743,7 @@ int mapif_parse_Registry(int fd)
|
||||
{
|
||||
int j,p,len, max;
|
||||
struct accreg *reg=accreg_pt;
|
||||
RFIFOHEAD(fd);
|
||||
|
||||
memset(accreg_pt,0,sizeof(struct accreg));
|
||||
switch (RFIFOB(fd, 12)) {
|
||||
case 3: //Character registry
|
||||
@ -770,26 +775,23 @@ int mapif_parse_Registry(int fd)
|
||||
// Request the value of all registries.
|
||||
int mapif_parse_RegistryRequest(int fd)
|
||||
{
|
||||
RFIFOHEAD(fd);
|
||||
//Load Char Registry
|
||||
if (RFIFOB(fd,12))
|
||||
mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),3);
|
||||
if (RFIFOB(fd,12)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),3);
|
||||
//Load Account Registry
|
||||
if (RFIFOB(fd,11))
|
||||
mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),2);
|
||||
if (RFIFOB(fd,11)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),2);
|
||||
//Ask Login Server for Account2 values.
|
||||
if (RFIFOB(fd,10))
|
||||
request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6)-2);
|
||||
if (RFIFOB(fd,10)) request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6)-2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, char *name){
|
||||
static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, char *name)
|
||||
{
|
||||
WFIFOHEAD(fd, NAME_LENGTH+13);
|
||||
WFIFOW(fd, 0) =0x3806;
|
||||
WFIFOL(fd, 2) =account_id;
|
||||
WFIFOL(fd, 6) =char_id;
|
||||
WFIFOB(fd,10) =type;
|
||||
WFIFOB(fd,11) =flag;
|
||||
WFIFOW(fd, 0) = 0x3806;
|
||||
WFIFOL(fd, 2) = account_id;
|
||||
WFIFOL(fd, 6) = char_id;
|
||||
WFIFOB(fd,10) = type;
|
||||
WFIFOB(fd,11) = flag;
|
||||
memcpy(WFIFOP(fd, 12), name, NAME_LENGTH);
|
||||
WFIFOSET(fd, NAME_LENGTH+13);
|
||||
}
|
||||
@ -800,11 +802,10 @@ int mapif_parse_NameChangeRequest(int fd)
|
||||
char* name;
|
||||
int i;
|
||||
|
||||
RFIFOHEAD(fd);
|
||||
account_id = RFIFOL(fd, 2);
|
||||
char_id = RFIFOL(fd, 6);
|
||||
type = RFIFOB(fd, 10);
|
||||
name = RFIFOP(fd, 11);
|
||||
account_id = RFIFOL(fd,2);
|
||||
char_id = RFIFOL(fd,6);
|
||||
type = RFIFOB(fd,10);
|
||||
name = RFIFOP(fd,11);
|
||||
|
||||
// Check Authorised letters/symbols in the name
|
||||
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
@ -833,22 +834,17 @@ int mapif_parse_NameChangeRequest(int fd)
|
||||
int inter_parse_frommap(int fd)
|
||||
{
|
||||
int cmd;
|
||||
int len=0;
|
||||
RFIFOHEAD(fd);
|
||||
cmd=RFIFOW(fd,0);
|
||||
int len = 0;
|
||||
cmd = RFIFOW(fd,0);
|
||||
// inter鯖管轄かを調べる
|
||||
if(cmd < 0x3000 || cmd >= 0x3000 + (sizeof(inter_recv_packet_length)/
|
||||
sizeof(inter_recv_packet_length[0]) ) )
|
||||
if(cmd < 0x3000 || cmd >= 0x3000 + ARRAYLENGTH(inter_recv_packet_length) || inter_recv_packet_length[cmd - 0x3000] == 0)
|
||||
return 0;
|
||||
|
||||
if (inter_recv_packet_length[cmd-0x3000] == 0) //This is necessary, because otherwise we return 2 and the char server will just hang waiting for packets! [Skotlex]
|
||||
return 0;
|
||||
|
||||
// パケット長を調べる
|
||||
if((len = inter_check_length(fd, inter_recv_packet_length[cmd - 0x3000])) == 0)
|
||||
return 2;
|
||||
|
||||
switch(cmd){
|
||||
switch(cmd) {
|
||||
case 0x3000: mapif_parse_GMmessage(fd); break;
|
||||
case 0x3001: mapif_parse_WisRequest(fd); break;
|
||||
case 0x3002: mapif_parse_WisReply(fd); break;
|
||||
@ -857,17 +853,15 @@ int inter_parse_frommap(int fd)
|
||||
case 0x3005: mapif_parse_RegistryRequest(fd); break;
|
||||
case 0x3006: mapif_parse_NameChangeRequest(fd); break;
|
||||
default:
|
||||
if(inter_party_parse_frommap(fd))
|
||||
if( inter_party_parse_frommap(fd)
|
||||
|| inter_guild_parse_frommap(fd)
|
||||
|| inter_storage_parse_frommap(fd)
|
||||
|| inter_pet_parse_frommap(fd)
|
||||
|| inter_homunculus_parse_frommap(fd)
|
||||
)
|
||||
break;
|
||||
if(inter_guild_parse_frommap(fd))
|
||||
break;
|
||||
if(inter_storage_parse_frommap(fd))
|
||||
break;
|
||||
if(inter_pet_parse_frommap(fd))
|
||||
break;
|
||||
if(inter_homunculus_parse_frommap(fd)) //albator
|
||||
break;
|
||||
return 0;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
RFIFOSKIP(fd, len);
|
||||
@ -877,9 +871,8 @@ int inter_parse_frommap(int fd)
|
||||
// RFIFO check
|
||||
int inter_check_length(int fd, int length)
|
||||
{
|
||||
RFIFOHEAD(fd);
|
||||
if(length==-1){ // v-len packet
|
||||
if(RFIFOREST(fd)<4) // packet not yet
|
||||
if(length == -1) { // v-len packet
|
||||
if(RFIFOREST(fd) < 4) // packet not yet
|
||||
return 0;
|
||||
length = RFIFOW(fd, 2);
|
||||
}
|
||||
|
@ -690,12 +690,12 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
|
||||
return 1;
|
||||
}
|
||||
if ((flag == MSG_DEBUG && !SHOW_DEBUG_MSG) ||
|
||||
(flag == MSG_INFORMATION && msg_silent&1) ||
|
||||
(flag == MSG_STATUS && msg_silent&2) ||
|
||||
(flag == MSG_NOTICE && msg_silent&4) ||
|
||||
(flag == MSG_WARNING && msg_silent&8) ||
|
||||
(flag == MSG_ERROR && msg_silent&16) ||
|
||||
(flag == MSG_SQL && msg_silent&16))
|
||||
(flag == MSG_INFORMATION && msg_silent&1) ||
|
||||
(flag == MSG_STATUS && msg_silent&2) ||
|
||||
(flag == MSG_NOTICE && msg_silent&4) ||
|
||||
(flag == MSG_WARNING && msg_silent&8) ||
|
||||
(flag == MSG_ERROR && msg_silent&16) ||
|
||||
(flag == MSG_SQL && msg_silent&16))
|
||||
return 0; //Do not print it.
|
||||
|
||||
if (timestamp_format[0])
|
||||
|
@ -612,7 +612,7 @@ int do_sendrecv(int next)
|
||||
|
||||
if(session[i]->eof) //func_send can't free a session, this is safe.
|
||||
{ //Finally, even if there is no data to parse, connections signalled eof should be closed, so we call parse_func [Skotlex]
|
||||
session[i]->func_parse(i); //This should close the session inmediately.
|
||||
session[i]->func_parse(i); //This should close the session immediately.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -132,7 +132,7 @@ struct auth_data {
|
||||
char last_ip[16]; // save of last IP of connection
|
||||
char memo[255]; // a memo field
|
||||
int account_reg2_num;
|
||||
struct global_reg account_reg2[ACCOUNT_REG2_NUM]; // account script variables
|
||||
struct global_reg account_reg2[ACCOUNT_REG2_NUM]; // account script variables (stored on login server)
|
||||
} *auth_dat = NULL;
|
||||
|
||||
uint32 auth_num = 0, auth_max = 0;
|
||||
@ -1367,8 +1367,10 @@ int parse_fromchar(int fd)
|
||||
{
|
||||
uint32 i;
|
||||
int j, id;
|
||||
|
||||
uint32 ipl = session[fd]->client_addr;
|
||||
char ip[16];
|
||||
ip2str(ipl, ip);
|
||||
|
||||
for(id = 0; id < MAX_SERVERS; id++)
|
||||
if (server_fd[id] == fd)
|
||||
@ -1379,8 +1381,6 @@ 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);
|
||||
|
@ -726,6 +726,7 @@ int parse_fromchar(int fd)
|
||||
|
||||
uint32 ipl = session[fd]->client_addr;
|
||||
char ip[16];
|
||||
ip2str(ipl, ip);
|
||||
|
||||
for(id = 0; id < MAX_SERVERS; id++)
|
||||
if (server_fd[id] == fd)
|
||||
@ -736,8 +737,6 @@ 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;
|
||||
@ -1889,8 +1888,8 @@ void sql_config_read(const char* cfgName)
|
||||
char line[1024], w1[1024], w2[1024];
|
||||
FILE* fp = fopen(cfgName, "r");
|
||||
if(fp == NULL) {
|
||||
ShowFatalError("file not found: %s\n", cfgName);
|
||||
exit(1);
|
||||
ShowError("file not found: %s\n", cfgName);
|
||||
return;
|
||||
}
|
||||
ShowInfo("reading configuration file %s...\n", cfgName);
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
|
@ -8358,7 +8358,7 @@ int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* c
|
||||
|
||||
/*==========================================
|
||||
* modify homunculus intimacy [orn]
|
||||
*------------------------------------------o */
|
||||
*------------------------------------------*/
|
||||
int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
||||
{
|
||||
int friendly = 0;
|
||||
|
413
src/map/chrif.c
413
src/map/chrif.c
@ -30,7 +30,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free
|
||||
60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff
|
||||
6,-1,18, 7,-1,49,30,10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07
|
||||
6,30,-1,10,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, U->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f
|
||||
0,-1,10, 6,11,-1, 0, 0, // 2b10-2b17: U->2b10, U->2b11, U->2b12, U->2b13, U->2b14, U->2b15, U->2b16, U->2b17
|
||||
11,-1,10, 6,11,-1, 0,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, U->2b13, U->2b14, U->2b15, U->2b16, U->2b17
|
||||
-1,-1,-1,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f
|
||||
-1,10, 8,-1,-1,-1,-1,-1, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, F->2b24, F->2b25, F->2b26, F->2b27
|
||||
};
|
||||
@ -97,7 +97,7 @@ int other_mapserver_count=0; //Holds count of how many other map servers are onl
|
||||
//Interval at which map server sends number of connected users. [Skotlex]
|
||||
#define UPDATE_INTERVAL 10000
|
||||
//This define should spare writing the check in every function. [Skotlex]
|
||||
#define chrif_check(a) { if(!chrif_isconnect()) return a; }
|
||||
#define chrif_check(a) { if(!chrif_isconnected()) return a; }
|
||||
|
||||
|
||||
// sets char-server's user id
|
||||
@ -147,7 +147,7 @@ void chrif_setport(uint16 port)
|
||||
}
|
||||
|
||||
// says whether the char-server is connected or not
|
||||
int chrif_isconnect(void)
|
||||
int chrif_isconnected(void)
|
||||
{
|
||||
return (char_fd > 0 && session[char_fd] != NULL && chrif_state == 2);
|
||||
}
|
||||
@ -163,7 +163,8 @@ int chrif_save(struct map_session_data *sd, int flag)
|
||||
|
||||
if (!flag) //The flag check is needed to prevent 'nosave' taking effect when a jailed player logs out.
|
||||
pc_makesavestatus(sd);
|
||||
if(!chrif_isconnect())
|
||||
|
||||
if(!chrif_isconnected())
|
||||
{
|
||||
if (flag) sd->state.finalsave = 1; //Will save character on reconnect.
|
||||
return -1;
|
||||
@ -238,10 +239,9 @@ int chrif_sendmap(int fd)
|
||||
int chrif_recvmap(int fd)
|
||||
{
|
||||
int i, j;
|
||||
uint32 ip;
|
||||
uint16 port;
|
||||
ip = ntohl(RFIFOL(fd,4));
|
||||
port = ntohs(RFIFOW(fd,8));
|
||||
uint32 ip = ntohl(RFIFOL(fd,4));
|
||||
uint16 port = ntohs(RFIFOW(fd,8));
|
||||
|
||||
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
|
||||
map_setipport(RFIFOW(fd,i), ip, port);
|
||||
}
|
||||
@ -256,15 +256,11 @@ int chrif_recvmap(int fd)
|
||||
int chrif_removemap(int fd)
|
||||
{
|
||||
int i, j;
|
||||
uint32 ip;
|
||||
uint16 port;
|
||||
uint32 ip = RFIFOL(fd,4);
|
||||
uint16 port = RFIFOW(fd,8);
|
||||
|
||||
ip = RFIFOL(fd, 4);
|
||||
port = RFIFOW(fd, 8);
|
||||
|
||||
for(i = 10, j = 0; i < RFIFOW(fd, 2); i += 4, j++){
|
||||
for(i = 10, j = 0; i < RFIFOW(fd, 2); i += 4, j++)
|
||||
map_eraseipport(RFIFOW(fd, i), ip, port);
|
||||
}
|
||||
|
||||
other_mapserver_count--;
|
||||
if(battle_config.etc_log)
|
||||
@ -284,10 +280,8 @@ int chrif_save_ack(int fd)
|
||||
}
|
||||
|
||||
// request to move a character between mapservers
|
||||
int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y, uint32 ip, uint16 port)
|
||||
int chrif_changemapserver(struct map_session_data* sd, short map, int x, int y, uint32 ip, uint16 port)
|
||||
{
|
||||
uint32 s_ip;
|
||||
|
||||
nullpo_retr(-1, sd);
|
||||
|
||||
chrif_check(-1);
|
||||
@ -298,11 +292,6 @@ int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sd->fd && sd->fd < fd_max && session[sd->fd])
|
||||
s_ip = session[sd->fd]->client_addr;
|
||||
else //Not connected? Can't retrieve IP
|
||||
s_ip = 0;
|
||||
|
||||
WFIFOHEAD(char_fd,35);
|
||||
WFIFOW(char_fd, 0) = 0x2b05;
|
||||
WFIFOL(char_fd, 2) = sd->bl.id;
|
||||
@ -315,7 +304,7 @@ int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y,
|
||||
WFIFOL(char_fd,24) = htonl(ip);
|
||||
WFIFOW(char_fd,28) = htons(port);
|
||||
WFIFOB(char_fd,30) = sd->status.sex;
|
||||
WFIFOL(char_fd,31) = htonl(s_ip); // not used
|
||||
WFIFOL(char_fd,31) = 0; // sd's IP, not used anymore
|
||||
WFIFOSET(char_fd,35);
|
||||
|
||||
return 0;
|
||||
@ -337,6 +326,7 @@ int chrif_changemapserverack(int fd)
|
||||
clif_authfail_fd(sd->fd, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sprintf(mapname, "%s.gat", mapindex_id2name(RFIFOW(fd,18)));
|
||||
clif_changemapserver(sd, mapname, RFIFOW(fd,20), RFIFOW(fd,22), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28)));
|
||||
|
||||
@ -380,6 +370,7 @@ int chrif_sendmapack(int fd)
|
||||
ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memcpy(wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
|
||||
ShowStatus("Map sending complete. Map Server is now online.\n");
|
||||
chrif_state = 2;
|
||||
@ -646,14 +637,10 @@ int chrif_changesex(int id, int sex)
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Answer after a request about a character name to do some operations (by Yor)
|
||||
* Used to answer of chrif_char_ask_name.
|
||||
* R 2b0f <accid>.l <name>.24B <type>.w <answer>.w
|
||||
* Reply to chrif_char_ask_name() (request to do some character operation)
|
||||
* type of operation:
|
||||
* 1: block
|
||||
* 2: ban
|
||||
* 3: unblock
|
||||
* 4: unban
|
||||
* 5: changesex
|
||||
* 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex
|
||||
* type of answer:
|
||||
* 0: login-server request done
|
||||
* 1: player not found
|
||||
@ -662,100 +649,43 @@ int chrif_changesex(int id, int sex)
|
||||
*------------------------------------------*/
|
||||
int chrif_char_ask_name_answer(int fd)
|
||||
{
|
||||
int acc;
|
||||
struct map_session_data *sd;
|
||||
struct map_session_data* sd;
|
||||
char* action;
|
||||
char output[256];
|
||||
char player_name[NAME_LENGTH];
|
||||
|
||||
acc = RFIFOL(fd,2); // account_id of who has asked (-1 if nobody)
|
||||
memcpy(player_name, RFIFOP(fd,6), NAME_LENGTH);
|
||||
player_name[NAME_LENGTH-1] = '\0';
|
||||
|
||||
int acc = RFIFOL(fd,2); // account_id of who has asked (-1 if nobody)
|
||||
char* player_name = (char*)RFIFOP(fd,6);
|
||||
uint16 type;
|
||||
uint16 answer;
|
||||
|
||||
type = RFIFOW(fd,30);
|
||||
answer = RFIFOW(fd,32);
|
||||
|
||||
sd = map_id2sd(acc);
|
||||
if (acc >= 0 && sd != NULL) {
|
||||
if (RFIFOW(fd, 32) == 1) // player not found
|
||||
sprintf(output, "The player '%s' doesn't exist.", player_name);
|
||||
else {
|
||||
switch(RFIFOW(fd, 30)) {
|
||||
case 1: // block
|
||||
switch(RFIFOW(fd, 32)) {
|
||||
case 0: // login-server request done
|
||||
sprintf(output, "Login-server has been asked to block the player '%s'.", player_name);
|
||||
break;
|
||||
//case 1: // player not found
|
||||
case 2: // gm level too low
|
||||
sprintf(output, "Your GM level don't authorise you to block the player '%s'.", player_name);
|
||||
break;
|
||||
case 3: // login-server offline
|
||||
sprintf(output, "Login-server is offline. Impossible to block the the player '%s'.", player_name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2: // ban
|
||||
switch(RFIFOW(fd, 32)) {
|
||||
case 0: // login-server request done
|
||||
sprintf(output, "Login-server has been asked to ban the player '%s'.", player_name);
|
||||
break;
|
||||
//case 1: // player not found
|
||||
case 2: // gm level too low
|
||||
sprintf(output, "Your GM level don't authorise you to ban the player '%s'.", player_name);
|
||||
break;
|
||||
case 3: // login-server offline
|
||||
sprintf(output, "Login-server is offline. Impossible to ban the the player '%s'.", player_name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3: // unblock
|
||||
switch(RFIFOW(fd, 32)) {
|
||||
case 0: // login-server request done
|
||||
sprintf(output, "Login-server has been asked to unblock the player '%s'.", player_name);
|
||||
break;
|
||||
//case 1: // player not found
|
||||
case 2: // gm level too low
|
||||
sprintf(output, "Your GM level don't authorise you to unblock the player '%s'.", player_name);
|
||||
break;
|
||||
case 3: // login-server offline
|
||||
sprintf(output, "Login-server is offline. Impossible to unblock the the player '%s'.", player_name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4: // unban
|
||||
switch(RFIFOW(fd, 32)) {
|
||||
case 0: // login-server request done
|
||||
sprintf(output, "Login-server has been asked to unban the player '%s'.", player_name);
|
||||
break;
|
||||
//case 1: // player not found
|
||||
case 2: // gm level too low
|
||||
sprintf(output, "Your GM level don't authorise you to unban the player '%s'.", player_name);
|
||||
break;
|
||||
case 3: // login-server offline
|
||||
sprintf(output, "Login-server is offline. Impossible to unban the the player '%s'.", player_name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 5: // changesex
|
||||
switch(RFIFOW(fd, 32)) {
|
||||
case 0: // login-server request done
|
||||
sprintf(output, "Login-server has been asked to change the sex of the player '%s'.", player_name);
|
||||
break;
|
||||
//case 1: // player not found
|
||||
case 2: // gm level too low
|
||||
sprintf(output, "Your GM level don't authorise you to change the sex of the player '%s'.", player_name);
|
||||
break;
|
||||
case 3: // login-server offline
|
||||
sprintf(output, "Login-server is offline. Impossible to change the sex of the the player '%s'.", player_name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (output[0] != '\0') {
|
||||
output[sizeof(output)-1] = '\0';
|
||||
clif_displaymessage(sd->fd, output);
|
||||
}
|
||||
} else
|
||||
if (acc < 0 || sd == NULL) {
|
||||
ShowError("chrif_char_ask_name_answer failed - player not online.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 1: action = "block"; break;
|
||||
case 2: action = "ban"; break;
|
||||
case 3: action = "unblock"; break;
|
||||
case 4: action = "unban"; break;
|
||||
case 5: action = "change the sex of"; break;
|
||||
default: action = "???"; break;
|
||||
}
|
||||
|
||||
switch(answer)
|
||||
{
|
||||
case 0: sprintf(output, "Login-server has been asked to %s the player '%20s'.", action, player_name); break;
|
||||
case 1: sprintf(output, "The player '%20s' doesn't exist.", player_name); break;
|
||||
case 2: sprintf(output, "Your GM level don't authorise you to %s the player '%20s'.", action, player_name); break;
|
||||
case 3: sprintf(output, "Login-server is offline. Impossible to %s the player '%20s'.", action, player_name); break;
|
||||
default: output[0] = '\0'; break;
|
||||
}
|
||||
|
||||
clif_displaymessage(sd->fd, output);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -859,22 +789,19 @@ int chrif_changedsex(int fd)
|
||||
*------------------------------------------*/
|
||||
int chrif_divorce(int char_id, int partner_id)
|
||||
{
|
||||
struct map_session_data *sd = NULL;
|
||||
struct map_session_data* sd;
|
||||
int i;
|
||||
|
||||
if (!char_id || !partner_id)
|
||||
if (!char_id || !partner_id || (sd = map_charid2sd(partner_id)) == NULL || sd->status.partner_id != char_id)
|
||||
return 0;
|
||||
|
||||
nullpo_retr(0, sd = map_charid2sd(partner_id));
|
||||
if (sd->status.partner_id == char_id) {
|
||||
int i;
|
||||
//離婚(相方は既にキャラが消えている筈なので)
|
||||
sd->status.partner_id = 0;
|
||||
//離婚(相方は既にキャラが消えている筈なので)
|
||||
sd->status.partner_id = 0;
|
||||
|
||||
//相方の結婚指輪を剥奪
|
||||
for(i = 0; i < MAX_INVENTORY; i++)
|
||||
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
|
||||
pc_delitem(sd, i, 1, 0);
|
||||
}
|
||||
//相方の結婚指輪を剥奪
|
||||
for(i = 0; i < MAX_INVENTORY; i++)
|
||||
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
|
||||
pc_delitem(sd, i, 1, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -917,60 +844,40 @@ int chrif_accountban(int fd)
|
||||
if (battle_config.etc_log)
|
||||
ShowNotice("chrif_accountban %d.\n", acc);
|
||||
sd = map_id2sd(acc);
|
||||
if (acc > 0) {
|
||||
if (sd != NULL) {
|
||||
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
|
||||
if (RFIFOB(fd,6) == 0) { // 0: change of statut, 1: ban
|
||||
switch (RFIFOL(fd,7)) { // status or final date of a banishment
|
||||
case 1: // 0 = Unregistered ID
|
||||
clif_displaymessage(sd->fd, "Your account has 'Unregistered'.");
|
||||
break;
|
||||
case 2: // 1 = Incorrect Password
|
||||
clif_displaymessage(sd->fd, "Your account has an 'Incorrect Password'...");
|
||||
break;
|
||||
case 3: // 2 = This ID is expired
|
||||
clif_displaymessage(sd->fd, "Your account has expired.");
|
||||
break;
|
||||
case 4: // 3 = Rejected from Server
|
||||
clif_displaymessage(sd->fd, "Your account has been rejected from server.");
|
||||
break;
|
||||
case 5: // 4 = You have been blocked by the GM Team
|
||||
clif_displaymessage(sd->fd, "Your account has been blocked by the GM Team.");
|
||||
break;
|
||||
case 6: // 5 = Your Game's EXE file is not the latest version
|
||||
clif_displaymessage(sd->fd, "Your Game's EXE file is not the latest version.");
|
||||
break;
|
||||
case 7: // 6 = Your are Prohibited to log in until %s
|
||||
clif_displaymessage(sd->fd, "Your account has been prohibited to log in.");
|
||||
break;
|
||||
case 8: // 7 = Server is jammed due to over populated
|
||||
clif_displaymessage(sd->fd, "Server is jammed due to over populated.");
|
||||
break;
|
||||
case 9: // 8 = No MSG (actually, all states after 9 except 99 are No MSG, use only this)
|
||||
clif_displaymessage(sd->fd, "Your account has not more authorised.");
|
||||
break;
|
||||
case 100: // 99 = This ID has been totally erased
|
||||
clif_displaymessage(sd->fd, "Your account has been totally erased.");
|
||||
break;
|
||||
default:
|
||||
clif_displaymessage(sd->fd, "Your account has not more authorised.");
|
||||
break;
|
||||
}
|
||||
} else if (RFIFOB(fd,6) == 1) { // 0: change of statut, 1: ban
|
||||
time_t timestamp;
|
||||
char tmpstr[2048];
|
||||
timestamp = (time_t)RFIFOL(fd,7); // status or final date of a banishment
|
||||
strcpy(tmpstr, "Your account has been banished until ");
|
||||
strftime(tmpstr + strlen(tmpstr), 24, "%d-%m-%Y %H:%M:%S", localtime(×tamp));
|
||||
clif_displaymessage(sd->fd, tmpstr);
|
||||
}
|
||||
clif_setwaitclose(sd->fd); // forced to disconnect for the change
|
||||
}
|
||||
} else {
|
||||
if (sd != NULL)
|
||||
ShowError("chrif_accountban failed - player not online.\n");
|
||||
|
||||
if (acc < 0 || sd == NULL) {
|
||||
ShowError("chrif_accountban failed - player not online.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
|
||||
if (RFIFOB(fd,6) == 0) // 0: change of statut, 1: ban
|
||||
{
|
||||
switch (RFIFOL(fd,7)) { // status or final date of a banishment
|
||||
case 1: clif_displaymessage(sd->fd, "Your account has 'Unregistered'."); break;
|
||||
case 2: clif_displaymessage(sd->fd, "Your account has an 'Incorrect Password'..."); break;
|
||||
case 3: clif_displaymessage(sd->fd, "Your account has expired."); break;
|
||||
case 4: clif_displaymessage(sd->fd, "Your account has been rejected from server."); break;
|
||||
case 5: clif_displaymessage(sd->fd, "Your account has been blocked by the GM Team."); break;
|
||||
case 6: clif_displaymessage(sd->fd, "Your Game's EXE file is not the latest version."); break;
|
||||
case 7: clif_displaymessage(sd->fd, "Your account has been prohibited to log in."); break;
|
||||
case 8: clif_displaymessage(sd->fd, "Server is jammed due to over populated."); break;
|
||||
case 9: clif_displaymessage(sd->fd, "Your account has not more authorised."); break;
|
||||
case 100: clif_displaymessage(sd->fd, "Your account has been totally erased."); break;
|
||||
default: clif_displaymessage(sd->fd, "Your account has not more authorised."); break;
|
||||
}
|
||||
}
|
||||
else if (RFIFOB(fd,6) == 1) // 0: change of statut, 1: ban
|
||||
{
|
||||
time_t timestamp;
|
||||
char tmpstr[2048];
|
||||
timestamp = (time_t)RFIFOL(fd,7); // status or final date of a banishment
|
||||
strcpy(tmpstr, "Your account has been banished until ");
|
||||
strftime(tmpstr + strlen(tmpstr), 24, "%d-%m-%Y %H:%M:%S", localtime(×tamp));
|
||||
clif_displaymessage(sd->fd, tmpstr);
|
||||
}
|
||||
|
||||
clif_setwaitclose(sd->fd); // forced to disconnect for the change
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -978,13 +885,11 @@ int chrif_accountban(int fd)
|
||||
//packet.w AID.L WHY.B 2+4+1 = 7byte
|
||||
int chrif_disconnectplayer(int fd)
|
||||
{
|
||||
struct map_session_data *sd;
|
||||
struct map_session_data* sd;
|
||||
|
||||
sd = map_id2sd(RFIFOL(fd, 2));
|
||||
|
||||
if(sd == NULL){
|
||||
if(sd == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!sd->fd)
|
||||
{ //No connection
|
||||
@ -995,27 +900,13 @@ int chrif_disconnectplayer(int fd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch(RFIFOB(fd, 6)){
|
||||
//clif_authfail_fd
|
||||
case 1: //server closed
|
||||
clif_authfail_fd(sd->fd, 1);
|
||||
break;
|
||||
|
||||
case 2: //someone else logged in
|
||||
clif_authfail_fd(sd->fd, 2);
|
||||
break;
|
||||
|
||||
case 3: //server overpopulated
|
||||
clif_authfail_fd(sd->fd, 4);
|
||||
break;
|
||||
|
||||
case 4: //out of time payd for .. (avail)
|
||||
clif_authfail_fd(sd->fd, 10);
|
||||
break;
|
||||
|
||||
case 5: //forced to dc by gm
|
||||
clif_authfail_fd(sd->fd, 15);
|
||||
break;
|
||||
switch(RFIFOB(fd, 6))
|
||||
{
|
||||
case 1: clif_authfail_fd(sd->fd, 1); break; //server closed
|
||||
case 2: clif_authfail_fd(sd->fd, 2); break; //someone else logged in
|
||||
case 3: clif_authfail_fd(sd->fd, 4); break; //server overpopulated
|
||||
case 4: clif_authfail_fd(sd->fd, 10); break; //out of available time paid for
|
||||
case 5: clif_authfail_fd(sd->fd, 15); break; //forced to dc by gm
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1047,26 +938,21 @@ int chrif_recvgmaccounts(int fd)
|
||||
* Request/Receive top 10 Fame character list
|
||||
*------------------------------------------*/
|
||||
|
||||
int chrif_updatefamelist(struct map_session_data *sd)
|
||||
int chrif_updatefamelist(struct map_session_data* sd)
|
||||
{
|
||||
char type;
|
||||
chrif_check(-1);
|
||||
|
||||
switch(sd->class_&MAPID_UPPERMASK) {
|
||||
case MAPID_BLACKSMITH:
|
||||
type = 1;
|
||||
break;
|
||||
case MAPID_ALCHEMIST:
|
||||
type = 2;
|
||||
break;
|
||||
case MAPID_TAEKWON:
|
||||
type = 3;
|
||||
break;
|
||||
switch(sd->class_ & MAPID_UPPERMASK)
|
||||
{
|
||||
case MAPID_BLACKSMITH: type = 1; break;
|
||||
case MAPID_ALCHEMIST: type = 2; break;
|
||||
case MAPID_TAEKWON: type = 3; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
WFIFOHEAD(char_fd, 12);
|
||||
WFIFOHEAD(char_fd, 11);
|
||||
WFIFOW(char_fd,0) = 0x2b10;
|
||||
WFIFOL(char_fd,2) = sd->status.char_id;
|
||||
WFIFOL(char_fd,6) = sd->status.fame;
|
||||
@ -1124,26 +1010,19 @@ int chrif_recvfamelist(int fd)
|
||||
|
||||
int chrif_updatefamelist_ack(int fd)
|
||||
{
|
||||
struct fame_list *list;
|
||||
char index;
|
||||
switch (RFIFOB(fd, 2))
|
||||
struct fame_list* list;
|
||||
uint8 index;
|
||||
switch (RFIFOB(fd,2))
|
||||
{
|
||||
case 1:
|
||||
list = smith_fame_list;
|
||||
break;
|
||||
case 2:
|
||||
list = chemist_fame_list;
|
||||
break;
|
||||
case 3:
|
||||
list = taekwon_fame_list;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
case 1: list = smith_fame_list; break;
|
||||
case 2: list = chemist_fame_list; break;
|
||||
case 3: list = taekwon_fame_list; break;
|
||||
default: return 0;
|
||||
}
|
||||
index = RFIFOB(fd, 3);
|
||||
if (index < 0 || index >= MAX_FAME_LIST)
|
||||
return 0;
|
||||
list[(int)index].fame = RFIFOL(fd, 4);
|
||||
list[index].fame = RFIFOL(fd,4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1191,8 +1070,9 @@ int chrif_save_scdata(struct map_session_data *sd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Retrieve and load sc_data for a player. [Skotlex]
|
||||
int chrif_load_scdata(int fd)
|
||||
{ //Retrieve and load sc_data for a player. [Skotlex]
|
||||
{
|
||||
#ifdef ENABLE_SC_SAVING
|
||||
struct map_session_data *sd;
|
||||
struct status_change_data *data;
|
||||
@ -1365,24 +1245,29 @@ void chrif_update_ip(int fd)
|
||||
int chrif_parse(int fd)
|
||||
{
|
||||
int packet_len, cmd;
|
||||
// only char-server can have an access to here.
|
||||
// so, if it isn't the char-server, we disconnect the session (fd != char_fd).
|
||||
if (fd != char_fd || session[fd]->eof) {
|
||||
if (fd == char_fd && chrif_connected == 1) {
|
||||
chrif_disconnect (fd);
|
||||
}
|
||||
else if (fd != char_fd)
|
||||
ShowDebug("chrif_parse: Disconnecting invalid session #%d (is not the char-server)\n", fd);
|
||||
|
||||
// only process data from the char-server
|
||||
if (fd != char_fd)
|
||||
{
|
||||
ShowDebug("chrif_parse: Disconnecting invalid session #%d (is not the char-server)\n", fd);
|
||||
do_close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (session[fd]->eof)
|
||||
{
|
||||
if (chrif_connected == 1)
|
||||
chrif_disconnect(fd);
|
||||
|
||||
do_close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (RFIFOREST(fd) >= 2) { //Infinite loop on broken pipe fix. [Skotlex]
|
||||
while (RFIFOREST(fd) >= 2)
|
||||
{
|
||||
cmd = RFIFOW(fd,0);
|
||||
if (cmd < 0x2af8 || cmd >= 0x2af8 + (sizeof(packet_len_table) / sizeof(packet_len_table[0])) ||
|
||||
packet_len_table[cmd-0x2af8] == 0) {
|
||||
|
||||
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(packet_len_table) || packet_len_table[cmd-0x2af8] == 0)
|
||||
{
|
||||
int r = intif_parse(fd); // intif‚É“n‚·
|
||||
|
||||
if (r == 1) continue; // intif‚Å<E2809A>ˆ—<CB86>‚µ‚½
|
||||
@ -1392,16 +1277,20 @@ int chrif_parse(int fd)
|
||||
ShowWarning("chrif_parse: session #%d, intif_parse failed -> disconnected.\n", fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
packet_len = packet_len_table[cmd-0x2af8];
|
||||
if (packet_len == -1) {
|
||||
if (packet_len == -1)
|
||||
{ // dynamic-length packet, second WORD holds the length
|
||||
if (RFIFOREST(fd) < 4)
|
||||
return 0;
|
||||
packet_len = RFIFOW(fd,2);
|
||||
}
|
||||
|
||||
if ((int)RFIFOREST(fd) < packet_len)
|
||||
return 0;
|
||||
|
||||
switch(cmd) {
|
||||
switch(cmd)
|
||||
{
|
||||
case 0x2af9: chrif_connectack(fd); break;
|
||||
case 0x2afb: chrif_sendmapack(fd); break;
|
||||
case 0x2afd: chrif_authok(fd); break;
|
||||
@ -1425,7 +1314,6 @@ int chrif_parse(int fd)
|
||||
case 0x2b20: chrif_removemap(fd); break;
|
||||
case 0x2b21: chrif_save_ack(fd); break;
|
||||
case 0x2b22: chrif_updatefamelist_ack(fd); break;
|
||||
|
||||
default:
|
||||
if (battle_config.error_log)
|
||||
ShowError("chrif_parse : unknown packet (session #%d): 0x%x. Disconnecting.\n", fd, cmd);
|
||||
@ -1492,11 +1380,14 @@ int send_users_tochar(int tid, unsigned int tick, int id, int data)
|
||||
int check_connect_char_server(int tid, unsigned int tick, int id, int data)
|
||||
{
|
||||
static int displayed = 0;
|
||||
if (char_fd <= 0 || session[char_fd] == NULL) {
|
||||
if (!displayed) {
|
||||
if (char_fd <= 0 || session[char_fd] == NULL)
|
||||
{
|
||||
if (!displayed)
|
||||
{
|
||||
ShowStatus("Attempting to connect to Char Server. Please wait.\n");
|
||||
displayed = 1;
|
||||
}
|
||||
|
||||
chrif_state = 0;
|
||||
char_fd = make_connection(char_ip, char_port);
|
||||
if (char_fd == -1)
|
||||
@ -1504,6 +1395,7 @@ int check_connect_char_server(int tid, unsigned int tick, int id, int data)
|
||||
char_fd = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
session[char_fd]->func_parse = chrif_parse;
|
||||
realloc_fifo(char_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
|
||||
|
||||
@ -1519,16 +1411,8 @@ int check_connect_char_server(int tid, unsigned int tick, int id, int data)
|
||||
srvinfo = 1;
|
||||
}
|
||||
#endif /* not TXT_ONLY */
|
||||
/* There is no need, the connection is TCP, so the packet is assured to arrive unless the connection dies [Skotlex]
|
||||
//If for some reason the next iteration (10 secs) we are still not connected,
|
||||
//assume the packets got lost, so we need to resend them. [Skotlex]
|
||||
if (chrif_state == 0)
|
||||
chrif_connect(char_fd);
|
||||
else if (chrif_state == 1)
|
||||
chrif_sendmap(char_fd);
|
||||
*/
|
||||
}
|
||||
if (chrif_isconnect()) displayed = 0;
|
||||
if (chrif_isconnected()) displayed = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1560,6 +1444,7 @@ int do_init_chrif(void)
|
||||
add_timer_func_list(send_usercount_tochar, "send_usercount_tochar");
|
||||
add_timer_func_list(send_users_tochar, "send_users_tochar");
|
||||
add_timer_func_list(auth_db_cleanup, "auth_db_cleanup");
|
||||
|
||||
add_timer_interval(gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000);
|
||||
#ifdef TXT_ONLY
|
||||
//Txt needs this more frequently because it is used for the online.html file.
|
||||
|
@ -18,7 +18,7 @@ void chrif_checkdefaultlogin(void);
|
||||
int chrif_setip(const char* ip);
|
||||
void chrif_setport(uint16 port);
|
||||
|
||||
int chrif_isconnect(void);
|
||||
int chrif_isconnected(void);
|
||||
|
||||
extern int chrif_connected;
|
||||
extern int other_mapserver_count;
|
||||
|
@ -550,7 +550,7 @@ int clif_authok(struct map_session_data *sd)
|
||||
* 4 - server full -> MsgStringTable[264]
|
||||
* 5 - underaged -> MsgStringTable[305]
|
||||
* 9 - too many connections from this ip -> MsgStringTable[529]
|
||||
* 10 - payed time has ended -> MsgStringTable[530]
|
||||
* 10 - out of available time paid for -> MsgStringTable[530]
|
||||
* 15 - disconnected by a GM -> if( servicetype == taiwan ) MsgStringTable[579]
|
||||
* other - disconnected -> MsgStringTable[3]
|
||||
*/
|
||||
@ -581,17 +581,14 @@ void clif_updatemaxid(int account_id, int char_id)
|
||||
*------------------------------------------*/
|
||||
int clif_charselectok(int id)
|
||||
{
|
||||
struct map_session_data *sd;
|
||||
struct map_session_data* sd;
|
||||
int fd;
|
||||
|
||||
if ((sd = map_id2sd(id)) == NULL)
|
||||
return 1;
|
||||
|
||||
if (!sd->fd)
|
||||
if ((sd = map_id2sd(id)) == NULL || !sd->fd)
|
||||
return 1;
|
||||
|
||||
fd = sd->fd;
|
||||
WFIFOHEAD(fd, packet_len(0xb3));
|
||||
WFIFOHEAD(fd,packet_len(0xb3));
|
||||
WFIFOW(fd,0) = 0xb3;
|
||||
WFIFOB(fd,2) = 1;
|
||||
WFIFOSET(fd,packet_len(0xb3));
|
||||
@ -2809,18 +2806,18 @@ int clif_initialstatus(struct map_session_data *sd)
|
||||
buf=WFIFOP(fd,0);
|
||||
|
||||
WBUFW(buf,0)=0xbd;
|
||||
WBUFW(buf,2)=(sd->status.status_point > SHRT_MAX)? SHRT_MAX:sd->status.status_point;
|
||||
WBUFB(buf,4)=(sd->status.str > UCHAR_MAX)? UCHAR_MAX:sd->status.str;
|
||||
WBUFW(buf,2)=min(sd->status.status_point, SHRT_MAX);
|
||||
WBUFB(buf,4)=min(sd->status.str, UCHAR_MAX);
|
||||
WBUFB(buf,5)=pc_need_status_point(sd,SP_STR);
|
||||
WBUFB(buf,6)=(sd->status.agi > UCHAR_MAX)? UCHAR_MAX:sd->status.agi;
|
||||
WBUFB(buf,6)=min(sd->status.agi, UCHAR_MAX);
|
||||
WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI);
|
||||
WBUFB(buf,8)=(sd->status.vit > UCHAR_MAX)? UCHAR_MAX:sd->status.vit;
|
||||
WBUFB(buf,8)=min(sd->status.vit, UCHAR_MAX);
|
||||
WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT);
|
||||
WBUFB(buf,10)=(sd->status.int_ > UCHAR_MAX)? UCHAR_MAX:sd->status.int_;
|
||||
WBUFB(buf,10)=min(sd->status.int_, UCHAR_MAX);
|
||||
WBUFB(buf,11)=pc_need_status_point(sd,SP_INT);
|
||||
WBUFB(buf,12)=(sd->status.dex > UCHAR_MAX)? UCHAR_MAX:sd->status.dex;
|
||||
WBUFB(buf,12)=min(sd->status.dex, UCHAR_MAX);
|
||||
WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX);
|
||||
WBUFB(buf,14)=(sd->status.luk > UCHAR_MAX)? UCHAR_MAX:sd->status.luk;
|
||||
WBUFB(buf,14)=min(sd->status.luk, UCHAR_MAX);
|
||||
WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK);
|
||||
|
||||
WBUFW(buf,16) = sd->battle_status.batk + sd->battle_status.rhw.atk + sd->battle_status.lhw->atk;
|
||||
@ -3797,7 +3794,7 @@ int clif_damage(struct block_list *src,struct block_list *dst,unsigned int tick,
|
||||
WBUFW(buf,22)=damage?div:0;
|
||||
WBUFW(buf,27)=damage2?div:0;
|
||||
} else {
|
||||
WBUFW(buf,22)=(damage > SHRT_MAX)?SHRT_MAX:damage;
|
||||
WBUFW(buf,22)=min(damage, SHRT_MAX);
|
||||
WBUFW(buf,27)=damage2;
|
||||
}
|
||||
WBUFW(buf,24)=div;
|
||||
@ -4457,7 +4454,7 @@ int clif_skill_nodamage(struct block_list *src,struct block_list *dst,int skill_
|
||||
|
||||
WBUFW(buf,0)=0x11a;
|
||||
WBUFW(buf,2)=skill_id;
|
||||
WBUFW(buf,4)=(heal > SHRT_MAX)? SHRT_MAX:heal;
|
||||
WBUFW(buf,4)=min(heal, SHRT_MAX);
|
||||
WBUFL(buf,6)=dst->id;
|
||||
WBUFL(buf,10)=src?src->id:0;
|
||||
WBUFB(buf,14)=fail;
|
||||
@ -6734,42 +6731,43 @@ int clif_guild_emblem(struct map_session_data *sd,struct guild *g)
|
||||
WFIFOSET(fd,WFIFOW(fd,2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* ƒMƒ‹ƒhƒXƒLƒ‹‘—<EFBFBD>M
|
||||
* Send guild skills
|
||||
*------------------------------------------*/
|
||||
int clif_guild_skillinfo(struct map_session_data *sd)
|
||||
int clif_guild_skillinfo(struct map_session_data* sd)
|
||||
{
|
||||
int fd;
|
||||
int i,id,c,up=1;
|
||||
struct guild *g;
|
||||
struct guild* g;
|
||||
int i,c;
|
||||
|
||||
nullpo_retr(0, sd);
|
||||
|
||||
fd=sd->fd;
|
||||
g=guild_search(sd->status.guild_id);
|
||||
if(g==NULL)
|
||||
fd = sd->fd;
|
||||
g = guild_search(sd->status.guild_id);
|
||||
if(g == NULL)
|
||||
return 0;
|
||||
|
||||
WFIFOHEAD(fd, MAX_GUILDSKILL * 37 + 6);
|
||||
WFIFOW(fd,0)=0x0162;
|
||||
WFIFOW(fd,4)=g->skill_point;
|
||||
for(i=c=0;i<MAX_GUILDSKILL;i++){
|
||||
if(g->skill[i].id>0 && guild_check_skill_require(g,g->skill[i].id)){
|
||||
WFIFOW(fd,c*37+ 6) = id = g->skill[i].id;
|
||||
WFIFOW(fd,0) = 0x0162;
|
||||
WFIFOW(fd,4) = g->skill_point;
|
||||
for(i = 0, c = 0; i < MAX_GUILDSKILL; i++)
|
||||
{
|
||||
if(g->skill[i].id > 0 && guild_check_skill_require(g, g->skill[i].id))
|
||||
{
|
||||
int id = g->skill[i].id;
|
||||
WFIFOW(fd,c*37+ 6) = id;
|
||||
WFIFOW(fd,c*37+ 8) = skill_get_inf(id);
|
||||
WFIFOW(fd,c*37+10) = 0;
|
||||
WFIFOW(fd,c*37+12) = g->skill[i].lv;
|
||||
WFIFOW(fd,c*37+14) = skill_get_sp(id,g->skill[i].lv);
|
||||
WFIFOW(fd,c*37+16) = skill_get_range(id,g->skill[i].lv);
|
||||
WFIFOW(fd,c*37+14) = skill_get_sp(id, g->skill[i].lv);
|
||||
WFIFOW(fd,c*37+16) = skill_get_range(id, g->skill[i].lv);
|
||||
strncpy((char*)WFIFOP(fd,c*37+18), skill_get_name(id), NAME_LENGTH);
|
||||
if(g->skill[i].lv < guild_skill_get_max(id) && (sd == g->member[0].sd))
|
||||
up = 1;
|
||||
else
|
||||
up = 0;
|
||||
WFIFOB(fd,c*37+42)= up;
|
||||
WFIFOB(fd,c*37+42)= (g->skill[i].lv < guild_skill_get_max(id) && sd == g->member[0].sd) ? 1 : 0;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
WFIFOW(fd,2)=c*37+6;
|
||||
WFIFOW(fd,2) = c*37 + 6;
|
||||
WFIFOSET(fd,WFIFOW(fd,2));
|
||||
return 0;
|
||||
}
|
||||
@ -6778,7 +6776,7 @@ int clif_guild_skillinfo(struct map_session_data *sd)
|
||||
* Sends guild notice to client
|
||||
* R 016f <str1z>.60B <str2z>.120B
|
||||
*------------------------------------------*/
|
||||
int clif_guild_notice(struct map_session_data *sd,struct guild *g)
|
||||
int clif_guild_notice(struct map_session_data* sd, struct guild* g)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@ -6787,17 +6785,16 @@ int clif_guild_notice(struct map_session_data *sd,struct guild *g)
|
||||
|
||||
fd = sd->fd;
|
||||
|
||||
if ( !session_isActive(fd) ) //null pointer right here [Kevin]
|
||||
if ( !session_isActive(fd) )
|
||||
return 0;
|
||||
|
||||
if (fd <= 0)
|
||||
return 0;
|
||||
if(*g->mes1==0 && *g->mes2==0)
|
||||
if(g->mes1[0] == '\0' && g->mes2[0] == '\0')
|
||||
return 0;
|
||||
|
||||
WFIFOHEAD(fd,packet_len(0x16f));
|
||||
WFIFOW(fd,0)=0x16f;
|
||||
memcpy(WFIFOP(fd,2),g->mes1,60);
|
||||
memcpy(WFIFOP(fd,62),g->mes2,120);
|
||||
WFIFOW(fd,0) = 0x16f;
|
||||
memcpy(WFIFOP(fd,2), g->mes1, 60);
|
||||
memcpy(WFIFOP(fd,62), g->mes2, 120);
|
||||
WFIFOSET(fd,packet_len(0x16f));
|
||||
return 0;
|
||||
}
|
||||
@ -8960,6 +8957,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
|
||||
|
||||
if (!pc_takeitem(sd, fitem))
|
||||
break;
|
||||
|
||||
return;
|
||||
} while (0);
|
||||
// Client REQUIRES a fail packet or you can no longer pick items.
|
||||
@ -11717,10 +11715,10 @@ static int packetdb_readdb(void)
|
||||
//#0x0240
|
||||
-1, -1, -1, -1, -1, 3, 4, 8, -1, 3, 70, 4, 8,12, 4, 10,
|
||||
3, 32, -1, 3, 3, 5, 5, 8, 2, 3, -1, -1, 4,-1, 4, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
//#0x0280
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0
|
||||
};
|
||||
struct {
|
||||
void (*func)(int, struct map_session_data *);
|
||||
|
@ -116,7 +116,7 @@ struct item_data {
|
||||
unsigned value_notoc : 1;
|
||||
short no_equip;
|
||||
unsigned no_refine : 1; // [celest]
|
||||
unsigned delay_consume : 1; // Signifies items that are not consumed inmediately upon double-click [Skotlex]
|
||||
unsigned delay_consume : 1; // Signifies items that are not consumed immediately upon double-click [Skotlex]
|
||||
unsigned trade_restriction : 7; //Item restrictions mask [Skotlex]
|
||||
unsigned autoequip: 1;
|
||||
} flag;
|
||||
|
@ -792,7 +792,7 @@ int map_foreachinarea(int (*func)(struct block_list*,va_list),int m,int x0,int y
|
||||
|
||||
if (type&~BL_MOB)
|
||||
for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) {
|
||||
for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
|
||||
for(bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) {
|
||||
bl = map[m].block[bx+by*map[m].bxs];
|
||||
c = map[m].block_count[bx+by*map[m].bxs];
|
||||
for(i=0;i<c && bl;i++,bl=bl->next){
|
||||
@ -1597,19 +1597,19 @@ static void* create_charid2nick(DBKey key, va_list args)
|
||||
/*==========================================
|
||||
* charid_dbへ追加(返信待ちがあれば返信)
|
||||
*------------------------------------------*/
|
||||
void map_addchariddb(int charid, char *name)
|
||||
void map_addchariddb(int charid, char* name)
|
||||
{
|
||||
struct charid2nick *p;
|
||||
struct charid2nick* p;
|
||||
int req = 0;
|
||||
|
||||
p = idb_ensure(charid_db,charid,create_charid2nick);
|
||||
p = idb_ensure(charid_db, charid, create_charid2nick);
|
||||
req = p->req_id;
|
||||
p->req_id = 0;
|
||||
//We overwrite the nick anyway in case a different one arrived.
|
||||
memcpy(p->nick, name, NAME_LENGTH);
|
||||
|
||||
if (req) {
|
||||
struct map_session_data *sd = map_id2sd(req);
|
||||
struct map_session_data* sd = map_id2sd(req);
|
||||
if (sd) clif_solved_charname(sd,charid);
|
||||
}
|
||||
}
|
||||
@ -2775,8 +2775,8 @@ int map_config_read(char *cfgName)
|
||||
|
||||
fp = fopen(cfgName,"r");
|
||||
if (fp == NULL) {
|
||||
ShowFatalError("Map configuration file not found at: %s\n", cfgName);
|
||||
exit(1);
|
||||
ShowError("Map configuration file not found at: %s\n", cfgName);
|
||||
return 1;
|
||||
}
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
@ -3244,7 +3244,7 @@ static int map_abort_sub(DBKey key,void * data,va_list ap)
|
||||
void do_abort(void)
|
||||
{
|
||||
//Save all characters and then flush the inter-connection.
|
||||
if (!chrif_isconnect())
|
||||
if (!chrif_isconnected())
|
||||
{
|
||||
if (pc_db->size(pc_db))
|
||||
ShowFatalError("Server has crashed without a connection to the char-server, character data can't be saved!\n");
|
||||
|
@ -496,7 +496,7 @@ struct party_member_data {
|
||||
struct party_data {
|
||||
struct party party;
|
||||
struct party_member_data data[MAX_PARTY];
|
||||
unsigned char itemc; //For item distribution.
|
||||
uint8 itemc; //For item distribution, position of last picker in party
|
||||
struct {
|
||||
unsigned monk : 1; //There's at least one monk in party?
|
||||
unsigned sg : 1; //There's at least one Star Gladiator in party?
|
||||
|
@ -999,7 +999,7 @@ int mob_unlocktarget(struct mob_data *md,int tick)
|
||||
default:
|
||||
mob_stop_attack(md);
|
||||
if (battle_config.mob_ai&0x8)
|
||||
mob_stop_walking(md,1); //Inmediately stop chasing.
|
||||
mob_stop_walking(md,1); //Immediately stop chasing.
|
||||
md->state.skillstate = MSS_IDLE;
|
||||
md->next_walktime=tick+rand()%3000+3000;
|
||||
break;
|
||||
@ -2085,7 +2085,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
|
||||
exp += exp*(battle_config.exp_bonus_attacker*(count-1))/100.; //[Gengar]
|
||||
}
|
||||
|
||||
mexp = (exp > UINT_MAX)?UINT_MAX:(exp<1?1:(unsigned int)exp);
|
||||
mexp = (unsigned int)cap_value(exp, 1, UINT_MAX);
|
||||
|
||||
if(use_irc && irc_announce_mvp_flag)
|
||||
irc_announce_mvp(mvp_sd,md);
|
||||
|
@ -761,43 +761,46 @@ int party_exp_share(struct party_data *p,struct block_list *src,unsigned int bas
|
||||
}
|
||||
|
||||
//Does party loot. first holds the id of the player who has time priority to take the item.
|
||||
int party_share_loot(struct party_data *p, TBL_PC *sd, struct item *item_data, int first)
|
||||
int party_share_loot(struct party_data* p, TBL_PC* sd, struct item* item_data, int first)
|
||||
{
|
||||
TBL_PC *target=NULL;
|
||||
TBL_PC* target = NULL;
|
||||
int i;
|
||||
if (p && p->party.item&2 && (first || !(battle_config.party_share_type&1))) {
|
||||
if (p && p->party.item&2 && (first || !(battle_config.party_share_type&1)))
|
||||
{
|
||||
//item distribution to party members.
|
||||
if (battle_config.party_share_type&2) { //Round Robin
|
||||
TBL_PC *psd;
|
||||
if (battle_config.party_share_type&2)
|
||||
{ //Round Robin
|
||||
TBL_PC* psd;
|
||||
i = p->itemc;
|
||||
do {
|
||||
i++;
|
||||
if (i >= MAX_PARTY)
|
||||
i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc"
|
||||
if ((psd=p->data[i].sd)==NULL || sd->bl.m != psd->bl.m ||
|
||||
pc_isdead(psd) || (battle_config.idle_no_share && (
|
||||
psd->chatID || psd->vender_id || (psd->idletime < (last_tick - battle_config.idle_no_share)))
|
||||
))
|
||||
|
||||
if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) ||
|
||||
(battle_config.idle_no_share && (psd->chatID || psd->vender_id || last_tick - battle_config.idle_no_share > psd->idletime)) )
|
||||
continue;
|
||||
|
||||
if (pc_additem(psd,item_data,item_data->amount))
|
||||
continue; //Chosen char can't pick up loot.
|
||||
|
||||
//Successful pick.
|
||||
p->itemc = i;
|
||||
target = psd;
|
||||
break;
|
||||
} while (i != p->itemc);
|
||||
} else { //Random pick
|
||||
TBL_PC *psd[MAX_PARTY];
|
||||
int count=0;
|
||||
}
|
||||
else
|
||||
{ //Random pick
|
||||
TBL_PC* psd[MAX_PARTY];
|
||||
int count = 0;
|
||||
//Collect pick candidates
|
||||
for (i = 0; i < MAX_PARTY; i++) {
|
||||
if ((psd[count]=p->data[i].sd) && psd[count]->bl.m == sd->bl.m &&
|
||||
!pc_isdead(psd[count]) && (!battle_config.idle_no_share || (
|
||||
!psd[count]->chatID && !psd[count]->vender_id &&
|
||||
(psd[count]->idletime >= (last_tick - battle_config.idle_no_share)))
|
||||
))
|
||||
count++;
|
||||
if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) ||
|
||||
(battle_config.idle_no_share && (psd[count]->chatID || psd[count]->vender_id || last_tick - battle_config.idle_no_share > psd[count]->idletime)) )
|
||||
continue;
|
||||
|
||||
count++;
|
||||
}
|
||||
while (count > 0) { //Pick a random member.
|
||||
i = rand()%count;
|
||||
@ -812,16 +815,17 @@ int party_share_loot(struct party_data *p, TBL_PC *sd, struct item *item_data, i
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!target) { //Give it to the owner.
|
||||
target = sd;
|
||||
|
||||
if (!target) {
|
||||
target = sd; //Give it to the char that picked it up
|
||||
if ((i=pc_additem(sd,item_data,item_data->amount)))
|
||||
return i;
|
||||
}
|
||||
|
||||
if(log_config.enable_logs&0x8) //Logs items, taken by (P)layers [Lupus]
|
||||
log_pick_pc(target, "P", item_data->nameid, item_data->amount, item_data);
|
||||
//Logs
|
||||
if(battle_config.party_show_share_picker && target != sd){
|
||||
|
||||
if(battle_config.party_show_share_picker && target != sd) {
|
||||
char output[80];
|
||||
sprintf(output, "%s acquired %s.",target->status.name, itemdb_jname(item_data->nameid));
|
||||
clif_disp_onlyself(sd,output,strlen(output));
|
||||
|
@ -2920,8 +2920,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
|
||||
}
|
||||
}
|
||||
}
|
||||
//This function takes care of giving the item to whoever should have it
|
||||
//considering party-share options.
|
||||
|
||||
//This function takes care of giving the item to whoever should have it, considering party-share options.
|
||||
if ((flag = party_share_loot(p,sd,&fitem->item_data, fitem->first_get_id))) {
|
||||
clif_additem(sd,0,0,flag);
|
||||
return 1;
|
||||
@ -2929,7 +2929,6 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
|
||||
|
||||
//Display pickup animation.
|
||||
pc_stop_attack(sd);
|
||||
|
||||
clif_takeitem(&sd->bl,&fitem->bl);
|
||||
map_clearflooritem(fitem->bl.id);
|
||||
return 1;
|
||||
@ -3050,7 +3049,7 @@ int pc_useitem(struct map_session_data *sd,int n)
|
||||
sd->itemindex = n;
|
||||
amount = sd->status.inventory[n].amount;
|
||||
script = sd->inventory_data[n]->script;
|
||||
//Check if the item is to be consumed inmediately [Skotlex]
|
||||
//Check if the item is to be consumed immediately [Skotlex]
|
||||
if (sd->inventory_data[n]->flag.delay_consume)
|
||||
clif_useitemack(sd,n,amount,1);
|
||||
else {
|
||||
|
@ -3859,7 +3859,6 @@ BUILDIN_FUNC(charcommand); // [MouseJstr]
|
||||
BUILDIN_FUNC(movenpc); // [MouseJstr]
|
||||
BUILDIN_FUNC(message); // [MouseJstr]
|
||||
BUILDIN_FUNC(npctalk); // [Valaris]
|
||||
BUILDIN_FUNC(hasitems); // [Valaris]
|
||||
BUILDIN_FUNC(getlook); //Lorky [Lupus]
|
||||
BUILDIN_FUNC(getsavepoint); //Lorky [Lupus]
|
||||
BUILDIN_FUNC(npcspeed); // [Valaris]
|
||||
@ -4193,7 +4192,6 @@ struct script_function buildin_func[] = {
|
||||
BUILDIN_DEF(movenpc,"sii"), // [MouseJstr]
|
||||
BUILDIN_DEF(message,"s*"), // [MouseJstr]
|
||||
BUILDIN_DEF(npctalk,"*"), // [Valaris]
|
||||
BUILDIN_DEF(hasitems,"*"), // [Valaris]
|
||||
BUILDIN_DEF(mobcount,"ss"),
|
||||
BUILDIN_DEF(getlook,"i"),
|
||||
BUILDIN_DEF(getsavepoint,"i"),
|
||||
@ -11370,29 +11368,6 @@ BUILDIN_FUNC(npctalk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* hasitems (checks to see if player has any
|
||||
* items on them, if so will return a 1)
|
||||
* [Valaris]
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(hasitems)
|
||||
{
|
||||
int i;
|
||||
TBL_PC *sd;
|
||||
|
||||
sd=script_rid2sd(st);
|
||||
|
||||
for(i=0; i<MAX_INVENTORY; i++) {
|
||||
if(sd->status.inventory[i].amount && sd->status.inventory[i].nameid!=2364 && sd->status.inventory[i].nameid!=2365) {
|
||||
script_pushint(st,1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
script_pushint(st,0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
// change npc walkspeed [Valaris]
|
||||
BUILDIN_FUNC(npcspeed)
|
||||
{
|
||||
|
@ -3537,7 +3537,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
|
||||
)
|
||||
abra_skillid = 0; // reset to get a new id
|
||||
} while (abra_skillid == 0);
|
||||
abra_skilllv = skill_get_max(abra_skillid) > skilllv ? skilllv : skill_get_max(abra_skillid);
|
||||
abra_skilllv = min(skilllv, skill_get_max(abra_skillid));
|
||||
clif_skill_nodamage (src, bl, skillid, skilllv, 1);
|
||||
|
||||
if (sd)
|
||||
|
@ -39,7 +39,7 @@ int storage_guild_storagesaved(int guild_id); //Ack from char server that guild
|
||||
|
||||
int storage_comp_item(const void *_i1, const void *_i2);
|
||||
//int storage_comp_item(const struct item* i1, const struct item* i2);
|
||||
void sortage_sortitem(struct storage* stor);
|
||||
void sortage_gsortitem(struct guild_storage* gstor);
|
||||
void storage_sortitem(struct storage* stor);
|
||||
void storage_gsortitem(struct guild_storage* gstor);
|
||||
|
||||
#endif /* _STORAGE_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user