|
@@ -232,8 +232,9 @@ int clif_countusers(void)
|
|
|
struct map_session_data *sd;
|
|
|
|
|
|
for(i = 0; i < fd_max; i++) {
|
|
|
- if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd->state.auth &&
|
|
|
- !(battle_config.hide_GM_session && pc_isGM(sd)))
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd = (struct map_session_data*)session[i]->session_data) &&
|
|
|
+ sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd)))
|
|
|
users++;
|
|
|
}
|
|
|
return users;
|
|
@@ -253,10 +254,9 @@ int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) //rec
|
|
|
va_start(ap,func);
|
|
|
|
|
|
for(i = 0; i < fd_max; i++) {
|
|
|
- if ( session[i] ) {
|
|
|
+ if ( session[i] && session[i]->func_parse == clif_parse) {
|
|
|
sd = (struct map_session_data*)session[i]->session_data;
|
|
|
- if ( sd && session[i]->func_parse == clif_parse &&
|
|
|
- sd->state.auth && !sd->state.waitingdisconnect )
|
|
|
+ if ( sd && sd->state.auth && !sd->state.waitingdisconnect )
|
|
|
func(sd, ap);
|
|
|
}
|
|
|
}
|
|
@@ -394,9 +394,11 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
|
|
|
}
|
|
|
|
|
|
switch(type) {
|
|
|
- case ALL_CLIENT: // 全クライアントに送信
|
|
|
+ case ALL_CLIENT: //All player clients.
|
|
|
for (i = 0; i < fd_max; i++) {
|
|
|
- if (session[i] && (sd = (struct map_session_data *)session[i]->session_data) != NULL && sd->state.auth) {
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd = (struct map_session_data *)session[i]->session_data) != NULL&&
|
|
|
+ sd->state.auth) {
|
|
|
if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
|
|
|
WFIFOHEAD(i, len);
|
|
|
memcpy(WFIFOP(i,0), buf, len);
|
|
@@ -405,9 +407,10 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case ALL_SAMEMAP: // 同じマップの全クライアントに送信
|
|
|
+ case ALL_SAMEMAP: //All players on the same map
|
|
|
for(i = 0; i < fd_max; i++) {
|
|
|
- if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
|
|
|
sd->state.auth && sd->bl.m == bl->m) {
|
|
|
if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
|
|
|
WFIFOHEAD(i,len);
|
|
@@ -457,7 +460,8 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
|
|
|
break;
|
|
|
case CHAT_MAINCHAT: //[LuzZza]
|
|
|
for(i=1; i<fd_max; i++) {
|
|
|
- if(session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
|
|
|
sd->state.mainchat && sd->fd) {
|
|
|
WFIFOHEAD(sd->fd, len);
|
|
|
memcpy(WFIFOP(sd->fd,0), buf, len);
|
|
@@ -465,16 +469,16 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case PARTY_AREA: // 同じ画面内の全パーティーメンバに送信
|
|
|
- case PARTY_AREA_WOS: // 自分以外の同じ画面内の全パーティーメンバに送信
|
|
|
+ case PARTY_AREA:
|
|
|
+ case PARTY_AREA_WOS:
|
|
|
x0 = bl->x - AREA_SIZE;
|
|
|
y0 = bl->y - AREA_SIZE;
|
|
|
x1 = bl->x + AREA_SIZE;
|
|
|
y1 = bl->y + AREA_SIZE;
|
|
|
- case PARTY: // 全パーティーメンバに送信
|
|
|
- case PARTY_WOS: // 自分以外の全パーティーメンバに送信
|
|
|
- case PARTY_SAMEMAP: // 同じマップの全パーティーメンバに送信
|
|
|
- case PARTY_SAMEMAP_WOS: // 自分以外の同じマップの全パーティーメンバに送信
|
|
|
+ case PARTY:
|
|
|
+ case PARTY_WOS:
|
|
|
+ case PARTY_SAMEMAP:
|
|
|
+ case PARTY_SAMEMAP_WOS:
|
|
|
if (sd && sd->status.party_id)
|
|
|
p = party_search(sd->status.party_id);
|
|
|
|
|
@@ -505,18 +509,39 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
|
|
|
if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
|
|
|
break;
|
|
|
for (i = 1; i < fd_max; i++){ // partyspy [Syrus22]
|
|
|
- if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth && sd->fd && sd->partyspy) {
|
|
|
- if (sd->partyspy == p->party.party_id) {
|
|
|
- if (sd->fd && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
|
|
|
- WFIFOHEAD(sd->fd,len);
|
|
|
- memcpy(WFIFOP(sd->fd,0), buf, len);
|
|
|
- WFIFOSET(sd->fd,len);
|
|
|
- }
|
|
|
+
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
|
|
|
+ sd->state.auth && sd->fd && sd->partyspy == p->party.party_id)
|
|
|
+ {
|
|
|
+ if (sd->fd && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
|
|
|
+ WFIFOHEAD(sd->fd,len);
|
|
|
+ memcpy(WFIFOP(sd->fd,0), buf, len);
|
|
|
+ WFIFOSET(sd->fd,len);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
+ case DUEL:
|
|
|
+ case DUEL_WOS:
|
|
|
+ if (!sd || !sd->duel_group) break; //Invalid usage.
|
|
|
+
|
|
|
+ x0 = sd->duel_group; //Here we use x0 to store the duel group. [Skotlex]
|
|
|
+ for (i = 0; i < fd_max; i++) {
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd = (struct map_session_data *)session[i]->session_data) != NULL &&
|
|
|
+ sd->state.auth && sd->duel_group == x0) {
|
|
|
+ if (type == DUEL_WOS && bl->id == sd->bl.id)
|
|
|
+ continue;
|
|
|
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) {
|
|
|
+ WFIFOHEAD(i, len);
|
|
|
+ memcpy(WFIFOP(i,0), buf, len);
|
|
|
+ WFIFOSET(i,len);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
case SELF:
|
|
|
if (sd && sd->fd && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
|
|
|
WFIFOHEAD(sd->fd,len);
|
|
@@ -566,13 +591,13 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
|
|
|
if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
|
|
|
break;
|
|
|
for (i = 1; i < fd_max; i++){ // guildspy [Syrus22]
|
|
|
- if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) != NULL && sd->state.auth && sd->fd && sd->guildspy) {
|
|
|
- if (sd->guildspy == g->guild_id) {
|
|
|
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
|
|
|
- WFIFOHEAD(sd->fd,len);
|
|
|
- memcpy(WFIFOP(sd->fd,0), buf, len);
|
|
|
- WFIFOSET(sd->fd,len);
|
|
|
- }
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
|
|
|
+ sd->state.auth && sd->fd && sd->guildspy == g->guild_id) {
|
|
|
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
|
|
|
+ WFIFOHEAD(sd->fd,len);
|
|
|
+ memcpy(WFIFOP(sd->fd,0), buf, len);
|
|
|
+ WFIFOSET(sd->fd,len);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1324,7 +1349,9 @@ int clif_weather(int m) {
|
|
|
struct map_session_data *sd=NULL;
|
|
|
|
|
|
for(i = 0; i < fd_max; i++) {
|
|
|
- if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == m) {
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd = session[i]->session_data) != NULL &&
|
|
|
+ sd->state.auth && sd->bl.m == m) {
|
|
|
clif_weather_check(sd);
|
|
|
}
|
|
|
}
|
|
@@ -1696,7 +1723,8 @@ static int clif_delayquit(int tid, unsigned int tick, int id, int data) {
|
|
|
void clif_quitsave(int fd,struct map_session_data *sd)
|
|
|
{
|
|
|
if (sd->state.waitingdisconnect || //Was already waiting to be disconnected.
|
|
|
- !battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
|
|
|
+ !battle_config.prevent_logout ||
|
|
|
+ DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
|
|
|
map_quit(sd);
|
|
|
else if (sd->fd)
|
|
|
{ //Disassociate session from player (session is deleted after this function was called)
|
|
@@ -6069,7 +6097,9 @@ int clif_hpmeter(struct map_session_data *sd)
|
|
|
WBUFW(buf,8) = sd->battle_status.max_hp;
|
|
|
}
|
|
|
for (i = 0; i < fd_max; i++) {
|
|
|
- if (session[i] && (sd2 = (struct map_session_data*)session[i]->session_data) && sd != sd2 && sd2->state.auth) {
|
|
|
+ if (session[i] && session[i]->func_parse == clif_parse &&
|
|
|
+ (sd2 = (struct map_session_data*)session[i]->session_data) &&
|
|
|
+ sd != sd2 && sd2->state.auth) {
|
|
|
if (sd2->bl.m != sd->bl.m ||
|
|
|
sd2->bl.x < x0 || sd2->bl.y < y0 ||
|
|
|
sd2->bl.x > x1 || sd2->bl.y > y1 ||
|
|
@@ -7438,6 +7468,21 @@ int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+/*==========================================
|
|
|
+ * Displays a message using the guild-chat colors to the specified targets. [Skotlex]
|
|
|
+ *------------------------------------------
|
|
|
+ */
|
|
|
+void clif_disp_message(struct block_list *src, char *mes, int len, int type)
|
|
|
+{
|
|
|
+ unsigned char buf[1024];
|
|
|
+ if (!len) return;
|
|
|
+ WBUFW(buf, 0) = 0x17f;
|
|
|
+ WBUFW(buf, 2) = len + 5;
|
|
|
+ memcpy(WBUFP(buf,4), mes, len);
|
|
|
+ clif_send(buf, WBUFW(buf,2), src, type);
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
/*==========================================
|
|
|
*
|
|
|
*------------------------------------------
|
|
@@ -8020,10 +8065,10 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
|
|
|
//Check for characters with no connection (includes those that are using autotrade) [durf],[Skotlex]
|
|
|
if (old_sd->state.finalsave)
|
|
|
; //Ack has not arrived yet from char-server, be patient!
|
|
|
- else if (!old_sd->fd)
|
|
|
- map_quit(old_sd);
|
|
|
- else
|
|
|
+ else if (old_sd->fd)
|
|
|
clif_authfail_fd(old_sd->fd, 2); // same id
|
|
|
+ else
|
|
|
+ map_quit(old_sd);
|
|
|
clif_authfail_fd(fd, 8); // still recognizes last connection
|
|
|
} else {
|
|
|
sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
|
|
@@ -8837,11 +8882,10 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) {
|
|
|
case 0x01:
|
|
|
/* Rovert's Prevent logout option - Fixed [Valaris] */
|
|
|
if (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
|
|
|
- {
|
|
|
- //map_quit(sd); //A clif_quitsave is sent inmediately after this, so no need to quit yet. [Skotlex]
|
|
|
- chrif_charselectreq(sd);
|
|
|
+ { //Send to char-server for character selection.
|
|
|
+ chrif_charselectreq(sd, session[fd]->client_addr.sin_addr.s_addr);
|
|
|
} else {
|
|
|
- WFIFOHEAD(fd,packet_len_table[0x18b]);
|
|
|
+ WFIFOHEAD(fd,packet_len_table[0x18b]);
|
|
|
WFIFOW(fd,0)=0x18b;
|
|
|
WFIFOW(fd,2)=1;
|
|
|
|