git-svn-id: https://svn.code.sf.net/p/rathena/svn/athena@65 54d463be-8e91-2dee-dedb-b68131a5f0ec

This commit is contained in:
codemaster 2004-11-08 15:28:15 +00:00
parent 382c455bc3
commit 1f6f25d2d7
4 changed files with 593 additions and 509 deletions

View File

@ -812,6 +812,26 @@ int chrif_accountban(int fd)
return 0;
}
/*==========================================
*
*------------------------------------------
*/
int chrif_chardisconnect(struct map_session_data *sd)
{
nullpo_retr(-1, sd);
if(char_fd<=0)
return -1;
WFIFOW(char_fd,0)=0x2b18;
WFIFOL(char_fd,2)=sd->status.account_id;
WFIFOL(char_fd,6)=sd->status.char_id;
WFIFOSET(char_fd,10);
//printf("chrif: char disconnect: %d %s\n",sd->bl.id,sd->status.name);
return 0;
}
/*==========================================
* Receiving GM accounts and their levels from char-server by [Yor]
*------------------------------------------

View File

@ -24,6 +24,7 @@ int chrif_reloadGMdb(void);
int chrif_ragsrvinfo(int base_rate,int job_rate, int drop_rate);
int chrif_char_offline(struct map_session_data *sd);
int chrif_changesex(int id, int sex);
int chrif_chardisconnect(struct map_session_data *sd);
int do_init_chrif(void);

View File

@ -6,17 +6,17 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/types.h>
#include <time.h>
#ifdef _WIN32
#include <winsock.h>
#else
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include <time.h>
#include "socket.h"
#include "timer.h"
@ -380,8 +380,8 @@ int clif_countusers(void)
struct map_session_data *sd;
for(i=0;i<fd_max;i++){
if (session[i] && (sd = session[i]->session_data) && sd && sd->state.auth &&
!(battle_config.hide_GM_session && pc_isGM(sd)))
if(session[i] && (sd=session[i]->session_data) && sd->state.auth
&& !(battle_config.hide_GM_session && pc_isGM(sd)) )
users++;
}
return users;
@ -399,7 +399,7 @@ int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...)
va_start(ap,func);
for(i=0;i<fd_max;i++){
if (session[i] && (sd = session[i]->session_data) && sd && sd->state.auth)
if(session[i] && (sd=session[i]->session_data) && sd->state.auth)
func(sd,ap);
}
va_end(ap);
@ -433,7 +433,7 @@ int clif_send_sub(struct block_list *bl, va_list ap)
return 0;
break;
case AREA_WOC:
if ((sd && sd->chatID) || (bl && bl == src_bl))
if(sd->chatID || bl==src_bl)
return 0;
break;
case AREA_WOSC:
@ -461,7 +461,8 @@ int clif_send_sub(struct block_list *bl, va_list ap)
*
*------------------------------------------
*/
int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) {
int clif_send(unsigned char *buf,int len,struct block_list *bl,int type)
{
int i;
struct map_session_data *sd;
struct chat_data *cd;
@ -476,7 +477,7 @@ int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) {
switch(type){
case ALL_CLIENT: // 全クライアントに送信
for(i=0;i<fd_max;i++){
if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth) {
if(session[i] && (sd=session[i]->session_data) && sd->state.auth){
memcpy(WFIFOP(i,0),buf,len);
WFIFOSET(i,len);
}
@ -484,7 +485,8 @@ int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) {
break;
case ALL_SAMEMAP: // 同じマップの全クライアントに送信
for(i=0;i<fd_max;i++){
if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == bl->m) {
if(session[i] && (sd=session[i]->session_data) && sd->state.auth &&
sd->bl.m == bl->m){
memcpy(WFIFOP(i,0),buf,len);
WFIFOSET(i,len);
}
@ -652,7 +654,8 @@ int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) {
*
*------------------------------------------
*/
int clif_authok(struct map_session_data *sd) {
int clif_authok(struct map_session_data *sd)
{
int fd;
nullpo_retr(0, sd);
@ -696,7 +699,8 @@ int clif_authfail_fd(int fd, int type) {
*
*------------------------------------------
*/
int clif_charselectok(int id) {
int clif_charselectok(int id)
{
struct map_session_data *sd;
int fd;
@ -718,7 +722,8 @@ int clif_charselectok(int id) {
*
*------------------------------------------
*/
static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf) {
static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf)
{
int view;
nullpo_retr(0, fitem);
@ -744,7 +749,8 @@ static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf) {
*
*------------------------------------------
*/
int clif_dropflooritem(struct flooritem_data *fitem) {
int clif_dropflooritem(struct flooritem_data *fitem)
{
char buf[64];
nullpo_retr(0, fitem);
@ -761,7 +767,8 @@ int clif_dropflooritem(struct flooritem_data *fitem) {
*
*------------------------------------------
*/
int clif_clearflooritem(struct flooritem_data *fitem, int fd) {
int clif_clearflooritem(struct flooritem_data *fitem,int fd)
{
unsigned char buf[16];
nullpo_retr(0, fitem);
@ -783,7 +790,8 @@ int clif_clearflooritem(struct flooritem_data *fitem, int fd) {
*
*------------------------------------------
*/
int clif_clearchar(struct block_list *bl, int type) {
int clif_clearchar(struct block_list *bl,int type)
{
unsigned char buf[16];
nullpo_retr(0, bl);
@ -801,7 +809,8 @@ int clif_clearchar(struct block_list *bl, int type) {
return 0;
}
static int clif_clearchar_delay_sub(int tid, unsigned int tick, int id, int data) {
static int clif_clearchar_delay_sub(int tid,unsigned int tick,int id,int data)
{
struct block_list *bl = (struct block_list *)id;
clif_clearchar(bl,data);
@ -811,7 +820,7 @@ static int clif_clearchar_delay_sub(int tid, unsigned int tick, int id, int data
}
int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type) {
struct block_list *tmpbl = calloc(sizeof(struct block_list), 1);
struct block_list *tmpbl=(struct block_list *)aCalloc(1,sizeof(struct block_list));
if (tmpbl == NULL) {
printf("clif_clearchar_delay: out of memory !\n");
exit(1);
@ -826,7 +835,8 @@ int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type) {
*
*------------------------------------------
*/
int clif_clearchar_id(int id, int type, int fd) {
int clif_clearchar_id(int id,int type,int fd)
{
unsigned char buf[16];
WBUFW(buf,0) = 0x80;
@ -1172,7 +1182,8 @@ static int clif_mob0078(struct mob_data *md, unsigned char *buf)
* MOB表示2
*------------------------------------------
*/
static int clif_mob007b(struct mob_data *md, unsigned char *buf) {
static int clif_mob007b(struct mob_data *md,unsigned char *buf)
{
int level;
memset(buf,0,packet_db[0x7b].len);
@ -1199,8 +1210,10 @@ static int clif_mob007b(struct mob_data *md, unsigned char *buf) {
WBUFW(buf,34)=mob_get_clothes_color(md->class); //Add for player monster dye - Valaris
WBUFB(buf,49)=mob_get_sex(md->class);
} else
WBUFL(buf,22)=gettick();
if(md->class >= 1285 && md->class <= 1287 && md->guild_id) { // Added guardian emblems [Valaris]
struct guild *g;
struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name);
@ -1210,14 +1223,14 @@ static int clif_mob007b(struct mob_data *md, unsigned char *buf) {
WBUFL(buf,28)=gc->guild_id;
WBUFL(buf,24)=g->emblem_id;
}
}
} // End addition
WBUFPOS2(buf,50,md->bl.x,md->bl.y,md->to_x,md->to_y);
WBUFB(buf,56)=5;
WBUFB(buf,57)=5;
WBUFW(buf,58)=((level = battle_get_lv(&md->bl))>battle_config.max_lv)? battle_config.max_lv:level;
return packet_db[0x7b].len;
}
@ -1225,7 +1238,8 @@ static int clif_mob007b(struct mob_data *md, unsigned char *buf) {
*
*------------------------------------------
*/
static int clif_npc0078(struct npc_data *nd, unsigned char *buf) {
static int clif_npc0078(struct npc_data *nd,unsigned char *buf)
{
struct guild *g;
nullpo_retr(0, nd);
@ -1237,8 +1251,9 @@ static int clif_npc0078(struct npc_data *nd, unsigned char *buf) {
WBUFW(buf,6)=nd->speed;
WBUFW(buf,12)=nd->option;
WBUFW(buf,14)=nd->class;
//if ((nd->class == 722) && (nd->u.scr.guild_id > 0) && ((g=guild_search(nd->u.scr.guild_id)) != NULL))
if((nd->bl.subtype!=WARP) && (nd->class == 722) && (nd->u.scr.guild_id > 0) &&
if( (nd->bl.subtype!=WARP) &&
(nd->class == 722) &&
(nd->u.scr.guild_id > 0) &&
((g=guild_search(nd->u.scr.guild_id))) )
{
WBUFL(buf,22)=g->emblem_id;
@ -1286,7 +1301,8 @@ static int clif_npc007b(struct npc_data *nd, unsigned char *buf) {
*
*------------------------------------------
*/
static int clif_pet0078(struct pet_data *pd, unsigned char *buf) {
static int clif_pet0078(struct pet_data *pd,unsigned char *buf)
{
int view,level;
nullpo_retr(0, pd);
@ -1328,7 +1344,8 @@ static int clif_pet0078(struct pet_data *pd, unsigned char *buf) {
*
*------------------------------------------
*/
static int clif_pet007b(struct pet_data *pd, unsigned char *buf) {
static int clif_pet007b(struct pet_data *pd,unsigned char *buf)
{
int view,level;
nullpo_retr(0, pd);
@ -1371,7 +1388,8 @@ static int clif_pet007b(struct pet_data *pd, unsigned char *buf) {
*
*------------------------------------------
*/
static int clif_set01e1(struct map_session_data *sd, unsigned char *buf) {
static int clif_set01e1(struct map_session_data *sd,unsigned char *buf)
{
nullpo_retr(0, sd);
WBUFW(buf,0)=0x1e1;
@ -1385,7 +1403,8 @@ static int clif_set01e1(struct map_session_data *sd, unsigned char *buf) {
*
*------------------------------------------
*/
static int clif_set0192(int fd, int m, int x, int y, int type) {
static int clif_set0192(int fd,int m,int x,int y,int type)
{
WFIFOW(fd,0) = 0x192;
WFIFOW(fd,2) = x;
WFIFOW(fd,4) = y;
@ -1576,7 +1595,8 @@ int clif_spawnpet(struct pet_data *pd)
*
*------------------------------------------
*/
int clif_movepet(struct pet_data *pd) {
int clif_movepet(struct pet_data *pd)
{
unsigned char buf[256];
int len;
@ -1646,7 +1666,8 @@ int clif_walkok(struct map_session_data *sd)
*
*------------------------------------------
*/
int clif_movechar(struct map_session_data *sd) {
int clif_movechar(struct map_session_data *sd)
{
int fd;
int len;
unsigned char buf[256];
@ -1676,7 +1697,7 @@ int clif_movechar(struct map_session_data *sd) {
void clif_quitsave(int fd,struct map_session_data *sd)
{
map_quit(sd);
//chrif_chardisconnect(sd);
chrif_chardisconnect(sd);
}
/*==========================================
@ -1695,9 +1716,6 @@ static int clif_waitclose(int tid, unsigned int tick, int id, int data) {
*------------------------------------------
*/
void clif_setwaitclose(int fd) {
if((sd=session[fd]->session_data) == NULL
add_timer(gettick() + 1000, clif_waitclose, fd, 0);
else
add_timer(gettick() + 5000, clif_waitclose, fd, 0);
}
@ -1705,7 +1723,8 @@ void clif_setwaitclose(int fd) {
*
*------------------------------------------
*/
int clif_changemap(struct map_session_data *sd, char *mapname, int x, int y) {
int clif_changemap(struct map_session_data *sd,char *mapname,int x,int y)
{
int fd;
nullpo_retr(0, sd);
@ -1728,7 +1747,8 @@ int clif_changemap(struct map_session_data *sd, char *mapname, int x, int y) {
*
*------------------------------------------
*/
int clif_changemapserver(struct map_session_data *sd, char *mapname, int x, int y, int ip, int port) {
int clif_changemapserver(struct map_session_data *sd,char *mapname,int x,int y,int ip,int port)
{
int fd;
nullpo_retr(0, sd);
@ -1749,7 +1769,8 @@ int clif_changemapserver(struct map_session_data *sd, char *mapname, int x, int
*
*------------------------------------------
*/
int clif_fixpos(struct block_list *bl) {
int clif_fixpos(struct block_list *bl)
{
char buf[16];
nullpo_retr(0, bl);
@ -1768,7 +1789,8 @@ int clif_fixpos(struct block_list *bl) {
*
*------------------------------------------
*/
int clif_npcbuysell(struct map_session_data* sd, int id) {
int clif_npcbuysell(struct map_session_data* sd,int id)
{
int fd;
nullpo_retr(0, sd);
@ -1785,7 +1807,8 @@ int clif_npcbuysell(struct map_session_data* sd, int id) {
*
*------------------------------------------
*/
int clif_buylist(struct map_session_data *sd, struct npc_data *nd) {
int clif_buylist(struct map_session_data *sd,struct npc_data *nd)
{
struct item_data *id;
int fd,i,val;
@ -1817,7 +1840,8 @@ int clif_buylist(struct map_session_data *sd, struct npc_data *nd) {
*
*------------------------------------------
*/
int clif_selllist(struct map_session_data *sd) {
int clif_selllist(struct map_session_data *sd)
{
int fd,i,c=0,val;
nullpo_retr(0, sd);
@ -1847,7 +1871,8 @@ int clif_selllist(struct map_session_data *sd) {
*
*------------------------------------------
*/
int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) {
int clif_scriptmes(struct map_session_data *sd,int npcid,char *mes)
{
int fd;
nullpo_retr(0, sd);
@ -1866,7 +1891,8 @@ int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) {
*
*------------------------------------------
*/
int clif_scriptnext(struct map_session_data *sd,int npcid) {
int clif_scriptnext(struct map_session_data *sd,int npcid)
{
int fd;
nullpo_retr(0, sd);
@ -1883,7 +1909,8 @@ int clif_scriptnext(struct map_session_data *sd,int npcid) {
*
*------------------------------------------
*/
int clif_scriptclose(struct map_session_data *sd, int npcid) {
int clif_scriptclose(struct map_session_data *sd,int npcid)
{
int fd;
nullpo_retr(0, sd);
@ -1900,7 +1927,8 @@ int clif_scriptclose(struct map_session_data *sd, int npcid) {
*
*------------------------------------------
*/
int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
int clif_scriptmenu(struct map_session_data *sd,int npcid,char *mes)
{
int fd;
nullpo_retr(0, sd);
@ -1919,7 +1947,8 @@ int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
*
*------------------------------------------
*/
int clif_scriptinput(struct map_session_data *sd, int npcid) {
int clif_scriptinput(struct map_session_data *sd,int npcid)
{
int fd;
nullpo_retr(0, sd);
@ -1936,7 +1965,8 @@ int clif_scriptinput(struct map_session_data *sd, int npcid) {
*
*------------------------------------------
*/
int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
int clif_scriptinputstr(struct map_session_data *sd,int npcid)
{
int fd;
nullpo_retr(0, sd);
@ -1953,7 +1983,8 @@ int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
*
*------------------------------------------
*/
int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color) {
int clif_viewpoint(struct map_session_data *sd,int npc_id,int type,int x,int y,int id,int color)
{
int fd;
nullpo_retr(0, sd);
@ -1975,7 +2006,8 @@ int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int
*
*------------------------------------------
*/
int clif_cutin(struct map_session_data *sd, char *image, int type) {
int clif_cutin(struct map_session_data *sd,char *image,int type)
{
int fd;
nullpo_retr(0, sd);
@ -1993,7 +2025,8 @@ int clif_cutin(struct map_session_data *sd, char *image, int type) {
*
*------------------------------------------
*/
int clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
int clif_additem(struct map_session_data *sd,int n,int amount,int fail)
{
int fd,j;
unsigned char *buf;
@ -2585,7 +2618,7 @@ int clif_updatestatus(struct map_session_data *sd,int type)
WFIFOL(fd,4)=sd->matk2;
break;
// 00b1 終了
case SP_ZENY:
WFIFOW(fd,0)=0xb1;
if(sd->status.zeny < 0)
@ -4885,7 +4918,7 @@ int clif_displaymessage(const int fd, char* mes)
*/
int clif_GMmessage(struct block_list *bl,char* mes,int len,int flag)
{
unsigned char buf[255];
unsigned char buf[len+16];
//unsigned char *buf = ((len + 16) >= sizeof(lbuf)) ? malloc(len+16) : lbuf;
int lp = (flag&0x10) ? 8 : 4;
@ -6472,7 +6505,7 @@ int clif_guild_basicinfo(struct map_session_data *sd)
WFIFOL(fd,42)=0; // 人数?
memcpy(WFIFOP(fd,46),g->name,24);
memcpy(WFIFOP(fd,70),g->master,24);
memcpy(WFIFOP(fd,94),"",20); // 本拠地
for(i=0;i<MAX_GUILDCASTLE;i++){
gc=guild_castle_search(i);
if(!gc) continue;
@ -7064,7 +7097,8 @@ void clif_talkiebox(struct block_list *bl,char* talkie)
*
*------------------------------------------
*/
void clif_wedding_effect(struct block_list *bl) {
void clif_wedding_effect(struct block_list *bl)
{
unsigned char buf[6];
nullpo_retv(bl);
@ -7105,8 +7139,6 @@ void clif_callpartner(struct map_session_data *sd)
*/
void clif_sitting(int fd, struct map_session_data *sd)
{
int fd;
nullpo_retv(sd);
fd=sd->fd;
@ -7281,7 +7313,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd, int cmd)
return;
}
sd = session[fd]->session_data = calloc(sizeof(*sd), 1);
sd=session[fd]->session_data=(struct map_session_data *)aCalloc(1,sizeof(struct map_session_data));
if (sd == NULL) {
printf("out of memory : clif_parse_WantToConnection\n");
exit(1);
@ -7458,7 +7490,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd, int cmd)
*
*------------------------------------------
*/
void clif_parse_TickSend(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_TickSend(int fd,struct map_session_data *sd, int cmd)
{
nullpo_retv(sd);
sd->client_tick=RFIFOL(fd,packet_db[cmd].pos[0]);
@ -7499,7 +7532,8 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd, int cmd) {
sd->sc_data[SC_TRICKDEAD].timer !=-1 || //死んだふり
sd->sc_data[SC_BLADESTOP].timer !=-1 || //白刃取り
sd->sc_data[SC_SPIDERWEB].timer !=-1 || //スパイダーウェッブ
(sd->sc_data[SC_DANCING].timer !=-1 && sd->sc_data[SC_DANCING].val4)) //合奏スキル演奏中は動けない
(sd->sc_data[SC_DANCING].timer !=-1 && sd->sc_data[SC_DANCING].val4) //合奏スキル演奏中は動けない
) //
return;
if( (sd->status.option&2) && pc_checkskill(sd,RG_TUNNELDRIVE) <= 0)
return;
@ -7520,7 +7554,8 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd, int cmd) {
*
*------------------------------------------
*/
void clif_parse_QuitGame(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_QuitGame(int fd,struct map_session_data *sd, int cmd)
{
unsigned int tick=gettick();
struct skill_unit_group* sg;
@ -7544,14 +7579,15 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd, int cmd) {
WFIFOW(fd,2)=1;
}
WFIFOSET(fd,packet_db[0x18b].len);
clif_setwaitclose(fd);
}
/*==========================================
*
*------------------------------------------
*/
void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_GetCharNameRequest(int fd,struct map_session_data *sd, int cmd)
{
struct block_list *bl;
int account_id;
@ -7583,6 +7619,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd, int cmd)
ps=g->member[i].position;
}
if(ps>=0 && ps<MAX_GUILDPOSITION){
WFIFOW(fd, 0)=0x195;
if(p)
memcpy(WFIFOP(fd,30),p->name,24);
@ -7595,8 +7632,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd, int cmd)
}
}
WFIFOSET(fd,packet_db[0x95].len);
}
break;
} break;
case BL_PET:
memcpy(WFIFOP(fd,6),((struct pet_data*)bl)->name,24);
WFIFOSET(fd,packet_db[0x95].len);
@ -7752,7 +7788,8 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd, int cmd) {
*
*------------------------------------------
*/
void clif_parse_ChangeDir(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_ChangeDir(int fd,struct map_session_data *sd, int cmd)
{
short headdir,dir;
unsigned char buf[64];
@ -7777,7 +7814,8 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd, int cmd) {
*
*------------------------------------------
*/
void clif_parse_Emotion(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_Emotion(int fd,struct map_session_data *sd, int cmd)
{
int emotion;
unsigned char buf[64];
@ -7807,7 +7845,8 @@ void clif_parse_HowManyConnections(int fd, struct map_session_data *sd, int cmd)
*
*------------------------------------------
*/
void clif_parse_ActionRequest(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_ActionRequest(int fd, struct map_session_data *sd, int cmd)
{
unsigned int tick;
unsigned char buf[64];
int action_type, target_id;
@ -7855,14 +7894,14 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd, int cmd) {
case 0x02: // sitdown
if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 3) {
pc_stop_walking(sd,1);
skill_gangsterparadise(sd, 1); // ギャングスターパラダイス設定
skill_gangsterparadise(sd,1);/* ギャングスターパラダイス設定 */
pc_setsit(sd);
clif_sitting(fd,sd);
} else
clif_skill_fail(sd, 1, 0, 2);
break;
case 0x03: // standup
skill_gangsterparadise(sd, 0); // ギャングスターパラダイス解除
skill_gangsterparadise(sd,0);/* ギャングスターパラダイス解除 */
pc_setstand(sd);
WBUFW(buf, 0) = 0x8a;
WBUFL(buf, 2) = sd->bl.id;
@ -7876,7 +7915,8 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd, int cmd) {
*
*------------------------------------------
*/
void clif_parse_Restart(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_Restart(int fd,struct map_session_data *sd, int cmd)
{
int restarttype=RFIFOB(fd,packet_db[cmd].pos[0]);
nullpo_retv(sd);
@ -7899,9 +7939,10 @@ void clif_parse_Restart(int fd, struct map_session_data *sd, int cmd) {
} else {
WFIFOW(fd,0)=0x18b;
WFIFOW(fd,2)=1;
WFIFOSET(fd,packet_db[0x018b].len);
WFIFOSET(fd,packet_db[0x18b].len);
return;
}
chrif_charselectreq(sd);
break;
}
}
@ -7910,7 +7951,8 @@ void clif_parse_Restart(int fd, struct map_session_data *sd, int cmd) {
* Transmission of a wisp (S 0096 <len>.w <nick>.24B <message>.?B)
*------------------------------------------
*/
void clif_parse_Wis(int fd, struct map_session_data *sd, int cmd) { // S 0096 <len>.w <nick>.24B <message>.?B // rewritten by [Yor]
void clif_parse_Wis(int fd,struct map_session_data *sd, int cmd)
{
int len=RFIFOW(fd,packet_db[cmd].pos[0]);
if( sd && sd->sc_data &&
@ -7940,7 +7982,8 @@ void clif_parse_GMmessage(int fd, struct map_session_data *sd, int cmd) {
*
*------------------------------------------
*/
void clif_parse_TakeItem(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_TakeItem(int fd,struct map_session_data *sd, int cmd)
{
struct flooritem_data *fitem;
int map_object_id;
@ -7955,7 +7998,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd, int cmd) {
}
if( sd->npc_id!=0 || sd->vender_id != 0 || sd->opt1 > 0 ||
(sd->sc_data && (sd->sc_data[SC_TRICKDEAD].timer != -1 || //死んだふり
(sd->sc_data && (sd->sc_data[SC_AUTOCOUNTER].timer!=-1 || //オートカウンター
sd->sc_data[SC_BLADESTOP].timer!=-1 || //白刃取り
sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク
sd->sc_data[SC_NOCHAT].timer!=-1 )) ) //会話禁止
@ -8039,8 +8082,8 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd, int cmd)
clif_equipitemack(sd,index,0,0); // fail
return;
}
if(sd->status.inventory[index].attribute != 0)
{
if(sd->status.inventory[index].attribute != 0) { // 破壊されている
clif_equipitemack(sd,index,0,0); // fail
return;
}
@ -8364,16 +8407,22 @@ void clif_parse_SkillUp(int fd,struct map_session_data *sd, int cmd)
void clif_parse_UseSkillToId(int fd, struct map_session_data *sd, int cmd) {
int skillnum, skilllv,lv, target_id;
unsigned int tick=gettick();
struct block_list *bl;
nullpo_retv(sd);
if (sd->chatID || sd->npc_id != 0 || sd->vender_id != 0)
return;
if(map[sd->bl.m].flag.noskill) return;
if(sd->npc_id!=0 || sd->vender_id != 0) return;
if(sd->chatID) return;
skilllv = RFIFOW(fd,packet_db[cmd].pos[0]);
skillnum = RFIFOW(fd,packet_db[cmd].pos[1]);
target_id = RFIFOL(fd,packet_db[cmd].pos[2]);
bl=map_id2bl(target_id);
if(bl && mob_gvmobcheck(sd, bl) == 0)
return;
if(skillnotok(skillnum, sd))
return;
@ -8429,6 +8478,7 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd, int cmd) {
nullpo_retv(sd);
if(map[sd->bl.m].flag.noskill) return;
if(sd->npc_id!=0 || sd->vender_id != 0) return;
if(sd->chatID) return;
@ -8660,18 +8710,18 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd, int cmd) {
* 019c /lb等
*------------------------------------------
*/
void clif_parse_LGMmessage(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_LGMmessage(int fd,struct map_session_data *sd, int cmd)
{
int len = RFIFOW(fd,packet_db[cmd].pos[0]);
unsigned char buf[64];
nullpo_retv(sd);
if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
(pc_isGM(sd) >= get_atcommand_level(AtCommand_LocalBroadcast))) {
WBUFW(buf,0) = 0x9a;
WBUFW(buf,2) = len;
memcpy(WBUFP(buf,4), RFIFOP(fd,packet_db[cmd].pos[1]), len-packet_db[cmd].pos[1]);
clif_send(buf, len, &sd->bl, ALL_SAMEMAP);
WFIFOW(fd,0)=0x9a;
WFIFOW(fd,2)=len;
memcpy(WBUFP(fd,4), RFIFOP(fd,packet_db[cmd].pos[1]), len-packet_db[cmd].pos[1]);
clif_send(WFIFOP(fd,0), len, &sd->bl, ALL_SAMEMAP);
}
}
@ -8689,6 +8739,10 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd, int cmd) {
item_index = RFIFOW(fd,packet_db[cmd].pos[0])-2;
item_amount = RFIFOL(fd,packet_db[cmd].pos[1]);
if(item_index < 0 || item_index > MAX_INVENTORY) return;
if(item_amount <=0 ) return;
if(itemdb_isdropable(sd->status.inventory[item_index].nameid) == 0) return;
if (sd->state.storage_flag)
storage_guild_storageadd(sd, item_index, item_amount);
else
@ -8699,7 +8753,8 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd, int cmd) {
*
*------------------------------------------
*/
void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd, int cmd) {
void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd, int cmd)
{
int item_index,item_amount;
nullpo_retv(sd);
@ -8718,7 +8773,8 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd, int cmd) {
*
*------------------------------------------
*/
void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_MoveToKafraFromCart(int fd,struct map_session_data *sd, int cmd)
{
nullpo_retv(sd);
if (sd->npc_id != 0 || sd->vender_id != 0 || sd->trade_partner != 0) return;
@ -8733,7 +8789,8 @@ void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd, int cmd
*
*------------------------------------------
*/
void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_MoveFromKafraToCart(int fd,struct map_session_data *sd, int cmd)
{
nullpo_retv(sd);
if(sd->npc_id!=0 || sd->vender_id != 0) return;
@ -8747,7 +8804,8 @@ void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd, int cmd
*
*------------------------------------------
*/
void clif_parse_CloseKafra(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_CloseKafra(int fd,struct map_session_data *sd, int cmd)
{
nullpo_retv(sd);
if(sd->state.storage_flag)
@ -8831,7 +8889,8 @@ void clif_parse_PartyChangeOption(int fd,struct map_session_data *sd, int cmd)
*
*------------------------------------------
*/
void clif_parse_PartyMessage(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_PartyMessage(int fd,struct map_session_data *sd, int cmd)
{
nullpo_retv(sd);
if (is_atcommand(fd, sd, RFIFOP(fd, packet_db[cmd].pos[1]),0) != AtCommand_None)
@ -9024,7 +9083,8 @@ void clif_parse_GuildExplusion(int fd,struct map_session_data *sd, int cmd)
*
*------------------------------------------
*/
void clif_parse_GuildMessage(int fd,struct map_session_data *sd, int cmd) {
void clif_parse_GuildMessage(int fd,struct map_session_data *sd, int cmd)
{
nullpo_retv(sd);
if (is_atcommand(fd, sd, RFIFOP(fd, packet_db[cmd].pos[1]), 0) != AtCommand_None)
@ -9107,7 +9167,8 @@ void clif_parse_ChangePetName(int fd,struct map_session_data *sd, int cmd)
}
// Kick (right click menu for GM "(name) force to quit")
void clif_parse_GMKick(int fd, struct map_session_data *sd, int cmd) {
void clif_parse_GMKick(int fd,struct map_session_data *sd, int cmd)
{
struct block_list *target;
int tid = RFIFOL(fd,packet_db[cmd].pos[0]);

View File

@ -136,14 +136,14 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
class=rand()%1000+1001;
k=rand()%1000000;
}while((mob_db[class].max_hp <= 0 || mob_db[class].summonper[j] <= k ||
(lv<mob_db[class].lv && battle_config.random_monster_checklv==1)) && (i++) < 2000);
(lv<mob_db[class].lv && battle_config.random_monster_checklv)) && (i++) < 2000);
if(i>=2000){
class=mob_db[0].summonper[j];
}
}else{
return 0;
}
// if(battle_config.etc_log==1)
// if(battle_config.etc_log)
// printf("mobclass=%d try=%d\n",class,i);
}
if(sd){
@ -165,14 +165,14 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
md->bl.m=m;
md->bl.x=x;
md->bl.y=y;
if(r<0&&battle_config.dead_branch_active==1) md->mode=0x1+0x4+0x80; //移動してアクティブで反撃する
if(r<0&&battle_config.dead_branch_active) md->mode=0x1+0x4+0x80; //移動してアクティブで反撃する
md->m =m;
md->x0=x;
md->y0=y;
md->xs=0;
md->ys=0;
md->spawndelay1=-1; // Only once is a flag.
md->spawndelay2=-1; // Only once is a flag.
md->spawndelay1=-1; // 一度のみフラグ
md->spawndelay2=-1; // 一度のみフラグ
memcpy(md->npc_event,event,sizeof(md->npc_event));
@ -211,7 +211,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
max=(y1-y0+1)*(x1-x0+1)*3;
if(max>1000)max=1000;
if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>2000) // A summon is stopped if a value is unusual
if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>2000) // 値が異常なら召喚を止める
return 0;
for(i=0;i<amount;i++){
@ -221,11 +221,11 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
y=rand()%(y1-y0+1)+y0;
}while( ( (c=map_getcell(m,x,y))==1 || c==5)&& (++j)<max );
if(j>=max){
if(lx>=0){ // Since reference went wrong, the place which boiled before is used.
if(lx>=0){ // 検索に失敗したので以前に沸いた場所を使う
x=lx;
y=ly;
}else
return 0; // Since reference of the place which boils first went wrong, it stops.
return 0; // 最初に沸く場所の検索を失敗したのでやめる
}
id=mob_once_spawn(sd,mapname,x,y,mobname,class,1,event);
lx=x;
@ -506,7 +506,7 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data)
if(md->option&4)
skill_check_cloaking(&md->bl);
skill_unit_move(&md->bl,tick,1); // Inspection of a skill unit
skill_unit_move(&md->bl,tick,1); // スキルユニットの検査
}
if((i=calc_next_walk_step(md))>0){
i = i>>1;
@ -516,7 +516,7 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data)
md->state.state=MS_WALK;
if(md->walkpath.path_pos>=md->walkpath.path_len)
clif_fixmobpos(md); // When mob stops, retransmission current of a position.
clif_fixmobpos(md); // とまったときに位置の再送信
}
return 0;
}
@ -693,8 +693,8 @@ int mob_changestate(struct mob_data *md,int state,int type)
// Since it died, all aggressors' attack to this mob is stopped.
clif_foreachclient(mob_stopattacked,md->bl.id);
skill_unit_out_all(&md->bl,gettick(),1);
skill_status_change_clear(&md->bl,2); // The abnormalities in status are canceled.
skill_clear_unitgroup(&md->bl); // All skill unit groups are deleted.
skill_status_change_clear(&md->bl,2); // ステータス異常を解除する
skill_clear_unitgroup(&md->bl); // 全てのスキルユニットグループを削除する
skill_cleartimerskill(&md->bl);
if(md->deletetimer!=-1)
delete_timer(md->deletetimer,mob_timer_delete);
@ -726,11 +726,11 @@ static int mob_timer(int tid,unsigned int tick,int id,int data)
nullpo_retr(1, md=(struct mob_data*)bl);
if(!md->bl.type || md->bl.type!=BL_MOB)
if(md->bl.type!=BL_MOB)
return 1;
if(md->timer != tid){
if(battle_config.error_log==1)
if(battle_config.error_log)
printf("mob_timer %d != %d\n",md->timer,tid);
return 0;
}
@ -750,7 +750,7 @@ static int mob_timer(int tid,unsigned int tick,int id,int data)
mob_changestate(md,MS_IDLE,0);
break;
default:
if(battle_config.error_log==1)
if(battle_config.error_log)
printf("mob_timer : %d ?\n",md->state.state);
break;
}
@ -853,6 +853,7 @@ int mob_setdelayspawn(int id)
spawntime=spawntime1;
else
spawntime=spawntime2;
if(DIFF_TICK(spawntime3,spawntime)>0)
spawntime=spawntime3;
@ -1102,7 +1103,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range)
if( range>0 && range < ((dx>dy)?dx:dy) ) // 遠すぎる
return 0;
if( md->bl.x==bl->x && md->bl.y==bl->y ) // 同じャX
if( md->bl.x==bl->x && md->bl.y==bl->y ) // 同じマス
return 1;
// Obstacle judging
@ -1485,7 +1486,7 @@ static int mob_randomwalk(struct mob_data *md,int tick)
if(i+1>=retrycount){
md->move_fail_count++;
if(md->move_fail_count>1000){
if(battle_config.error_log==1)
if(battle_config.error_log)
printf("MOB cant move. random spawn %d, class = %d\n",md->bl.id,md->class);
md->move_fail_count=0;
mob_spawn(md->bl.id);
@ -1593,7 +1594,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
// アクティヴモンスターの策敵 (?? of a bitter taste TIVU monster)
if( (!md->target_id || md->state.targettype == NONE_ATTACKABLE) && mode&0x04 && !md->state.master_check &&
battle_config.monster_active_enable==1){
battle_config.monster_active_enable){
i=0;
if(md->state.special_mob_ai){
map_foreachinarea(mob_ai_sub_hard_activesearch,md->bl.m,
@ -1825,7 +1826,7 @@ static int mob_ai_sub_lazy(void * key,void * data,va_list app)
nullpo_retr(0, app);
nullpo_retr(0, ap=va_arg(app,va_list));
if(md==NULL)
if(md->bl.type!=BL_MOB)
return 0;
if(!md->bl.type || md->bl.type!=BL_MOB)
@ -1919,7 +1920,7 @@ static int mob_delay_item_drop(int tid,unsigned int tick,int id,int data)
temp_item.amount = ditem->amount;
temp_item.identify = !itemdb_isequip3(temp_item.nameid);
if(battle_config.item_auto_get==1){
if(battle_config.item_auto_get){
if(ditem->first_sd && (flag = pc_additem(ditem->first_sd,&temp_item,ditem->amount))){
clif_additem(ditem->first_sd,0,0,flag);
map_addflooritem(&temp_item,1,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
@ -1945,7 +1946,7 @@ static int mob_delay_item_drop2(int tid,unsigned int tick,int id,int data)
nullpo_retr(0, ditem=(struct delay_item_drop2 *)id);
if(battle_config.item_auto_get==1){
if(battle_config.item_auto_get){
if(ditem->first_sd && (flag = pc_additem(ditem->first_sd,&ditem->item_data,ditem->item_data.amount))){
clif_additem(ditem->first_sd,0,0,flag);
map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
@ -2071,7 +2072,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
// if(battle_config.battle_log)
// printf("mob_damage %d %d %d\n",md->hp,max_hp,damage);
if(md->bl.prev==NULL){
if(battle_config.error_log==1)
if(battle_config.error_log)
printf("mob_damage : BlockError!!\n");
return 0;
}
@ -2123,7 +2124,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
if(md->attacked_id <= 0 && md->state.special_mob_ai==0)
md->attacked_id = sd->bl.id;
}
if(src && src->type == BL_PET && battle_config.pet_attack_exp_to_master==1) {
if(src && src->type == BL_PET && battle_config.pet_attack_exp_to_master) {
struct pet_data *pd = (struct pet_data *)src;
nullpo_retr(0, pd);
for(i=0,minpos=0,mindmg=0x7fffffff;i<DAMAGELOG_SIZE;i++){
@ -2388,7 +2389,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
if(mob_db[md->class].dropitem[i].nameid <= 0)
continue;
drop_rate = mob_db[md->class].dropitem[i].p;
if(drop_rate <= 0 && battle_config.drop_rate0item==1)
if(drop_rate <= 0 && battle_config.drop_rate0item)
drop_rate = 1;
if(battle_config.drops_by_luk>0 && sd && md) drop_rate+=(sd->status.luk*battle_config.drops_by_luk)/100; // drops affected by luk [Valaris]
if(sd && md && battle_config.pk_mode==1 && (mob_db[md->class].lv - sd->status.base_level >= 20)) drop_rate*=1.25; // pk_mode increase drops if 20 level difference [Valaris]
@ -2474,7 +2475,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
if(mob_db[md->class].mvpitem[i].nameid <= 0)
continue;
drop_rate = mob_db[md->class].mvpitem[i].p;
if(drop_rate <= 0 && battle_config.drop_rate0item==1)
if(drop_rate <= 0 && battle_config.drop_rate0item)
drop_rate = 1;
if(drop_rate < battle_config.item_drop_mvp_min)
drop_rate = battle_config.item_drop_mvp_min;
@ -2512,7 +2513,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
// SCRIPT実行
if(md->npc_event[0]){
// if(battle_config.battle_log==1)
// if(battle_config.battle_log)
// printf("mob_damage : run event : %s\n",md->npc_event);
if(src && src->type == BL_PET)
sd = ((struct pet_data *)src)->msd;
@ -2735,12 +2736,13 @@ int mob_warp(struct mob_data *md,int m,int x,int y,int type)
mob_changestate(md,MS_IDLE,0);
if(type>0 && i==1000) {
if(battle_config.battle_log==1)
if(battle_config.battle_log)
printf("MOB %d warp to (%d,%d), class = %d\n",md->bl.id,x,y,md->class);
}
map_addblock(&md->bl);
if(type>0) {
if(type>0)
{
clif_spawnmob(md);
mob_warpslave(md,md->bl.x,md->bl.y);
}
@ -2995,7 +2997,7 @@ int mobskill_castend_id( int tid, unsigned int tick, int id,int data )
md->skilldelay[md->skillidx]=tick;
if(battle_config.mob_skill_log==1)
if(battle_config.mob_skill_log)
printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class);
mob_stop_walking(md,0);
@ -3079,7 +3081,7 @@ int mobskill_castend_pos( int tid, unsigned int tick, int id,int data )
return 0;
}
}
if(battle_config.monster_skill_nofootset==1) {
if(battle_config.monster_skill_nofootset) {
range = -1;
switch(md->skillid) {
case WZ_FIREPILLAR:
@ -3106,7 +3108,7 @@ int mobskill_castend_pos( int tid, unsigned int tick, int id,int data )
}
}
if(battle_config.monster_land_skill_limit==1) {
if(battle_config.monster_land_skill_limit) {
maxcount = skill_get_maxcount(md->skillid);
if(maxcount > 0) {
int i,c;
@ -3126,7 +3128,7 @@ int mobskill_castend_pos( int tid, unsigned int tick, int id,int data )
return 0;
md->skilldelay[md->skillidx]=tick;
if(battle_config.mob_skill_log==1)
if(battle_config.mob_skill_log)
printf("MOB skill castend skill=%d, class = %d\n",md->skillid,md->class);
mob_stop_walking(md,0);
@ -3209,7 +3211,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx)
break;
}
if(battle_config.mob_skill_log==1)
if(battle_config.mob_skill_log)
printf("MOB skill use target_id=%d skill=%d lv=%d cast=%d, class = %d\n",target->id,skill_id,skill_lv,casttime,md->class);
if(casttime>0 || forcecast){ // 詠唱が必要
@ -3305,7 +3307,7 @@ int mobskill_use_pos( struct mob_data *md,
md->skilldelay[skill_idx]=gettick();
md->state.skillcastcancel=ms->cancel;
if(battle_config.mob_skill_log==1)
if(battle_config.mob_skill_log)
printf("MOB skill use target_pos=(%d,%d) skill=%d lv=%d cast=%d, class = %d\n",
skill_x,skill_y,skill_id,skill_lv,casttime,md->class);