Daegaladh Posted July 21, 2012 Group: Developer Topic Count: 30 Topics Per Day: 0.01 Content Count: 239 Reputation: 147 Joined: 11/21/11 Last Seen: Yesterday at 11:34 AM Share Posted July 21, 2012 This bug is on Athena since it was created, so I think it's time to get rid of it... In Aegis, the NPCs with waitingrooms are always logged into the chatroom. Here's a bugfix I made with the help of SnakeDrak some time ago. But I need a core dev to check it and improve the code if possible. The code is functional and I was using it on my server for 2 years without any problem. Index: chat.c =================================================================== --- chat.c (revision 13405) +++ chat.c (working copy) @@ -106,7 +106,7 @@ nullpo_retr(0, sd); cd = (struct chat_data*)map_id2bl(chatid); - if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->vender_id || sd->chatID || cd->users >= cd->limit ) + if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->vender_id || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit ) { clif_joinchatfail(sd,0); return 0; Index: clif.c =================================================================== --- clif.c (revision 13405) +++ clif.c (working copy) @@ -2861,7 +2861,7 @@ WBUFL(buf, 4) = cd->owner->id; WBUFL(buf, 8) = cd->bl.id; WBUFW(buf,12) = cd->limit; - WBUFW(buf,14) = cd->users; + WBUFW(buf,14) = (cd->owner->type == BL_NPC) ? cd->users+1 : cd->users; WBUFB(buf,16) = type; strncpy((char*)WBUFP(buf,17), cd->title, strlen(cd->title)); // not zero-terminated @@ -2892,7 +2892,7 @@ WBUFL(buf, 4) = cd->usersd[0]->bl.id; WBUFL(buf, 8) = cd->bl.id; WBUFW(buf,12) = cd->limit; - WBUFW(buf,14) = cd->users; + WBUFW(buf,14) = (cd->owner->type == BL_NPC) ? cd->users+1 : cd->users; WBUFB(buf,16) = cd->pub; strncpy((char*)WBUFP(buf,17), cd->title, strlen(cd->title)); // not zero-terminated @@ -2948,7 +2948,7 @@ int clif_joinchatok(struct map_session_data *sd,struct chat_data* cd) { int fd; - int i; + int i,t; nullpo_retr(0, sd); nullpo_retr(0, cd); @@ -2956,13 +2956,25 @@ fd = sd->fd; if (!session_isActive(fd)) return 0; - WFIFOHEAD(fd, 8 + (28*cd->users)); + + t = (int)(cd->owner->type == BL_NPC); + WFIFOHEAD(fd, 8 + (28*(cd->users+t))); WFIFOW(fd, 0) = 0xdb; - WFIFOW(fd, 2) = 8 + (28*cd->users); + WFIFOW(fd, 2) = 8 + (28*(cd->users+t)); WFIFOL(fd, 4) = cd->bl.id; + + if(cd->owner->type == BL_NPC){ + WFIFOL(fd, 30) = 1; + WFIFOL(fd, 8) = 0; + memcpy(WFIFOP(fd, 12), ((struct npc_data *)cd->owner)->name, NAME_LENGTH); + for (i = 0; i < cd->users; i++) { + WFIFOL(fd, 8+(i+1)*28) = 1; + memcpy(WFIFOP(fd, 8+(i+t)*28+4), cd->usersd[i]->status.name, NAME_LENGTH); + } + }else for (i = 0; i < cd->users; i++) { WFIFOL(fd, 8+i*28) = (i != 0 || cd->owner->type == BL_NPC); - memcpy(WFIFOP(fd, 8+i*28+4), cd->usersd[i]->status.name, NAME_LENGTH); + memcpy(WFIFOP(fd, 8+(i+t)*28+4), cd->usersd[i]->status.name, NAME_LENGTH); } WFIFOSET(fd, WFIFOW(fd, 2)); Link to comment Share on other sites More sharing options...
Recommended Posts