summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-10 03:58:15 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-10 03:58:15 +0000
commite2856893e1bdaba52c1ff3e0cbd7a4635e7af90b (patch)
tree2bb49221533209ffdbb7e9cecb107fc734d57872 /src/map/clif.c
parent8542722b5f295eb8d282cc22f894ec49b5368f40 (diff)
downloadhercules-e2856893e1bdaba52c1ff3e0cbd7a4635e7af90b.tar.gz
hercules-e2856893e1bdaba52c1ff3e0cbd7a4635e7af90b.tar.bz2
hercules-e2856893e1bdaba52c1ff3e0cbd7a4635e7af90b.tar.xz
hercules-e2856893e1bdaba52c1ff3e0cbd7a4635e7af90b.zip
- Added structure party_data and party_member_data to the map server to hold party-specific required information about parties including Monk/TK/SG/SN states and party member count.
- party Hp updates are no longer done each time the Hp is modified, but together with the party xy timer. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7083 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c139
1 files changed, 68 insertions, 71 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 7f06c1e20..bfa90ff8d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -348,7 +348,7 @@ 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 i;
struct map_session_data *sd = NULL;
- struct party *p = NULL;
+ struct party_data *p = NULL;
struct guild *g = NULL;
int x0 = 0, x1 = 0, y0 = 0, y1 = 0;
@@ -445,33 +445,33 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
if (p) {
for(i=0;i<MAX_PARTY;i++){
- if ((sd = p->member[i].sd) != NULL) {
- if (!sd->fd || session[sd->fd] == NULL || sd->state.auth == 0
- || session[sd->fd]->session_data == NULL || sd->packet_ver > MAX_PACKET_VER)
- continue;
-
- if (sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS))
- continue;
-
- if (type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m) // マップチェック
- continue;
-
- if ((type == PARTY_AREA || type == PARTY_AREA_WOS) &&
- (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1))
- continue;
-
- 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 ((sd = p->data[i].sd) == NULL)
+ continue;
+ if (!sd->fd || session[sd->fd] == NULL || sd->state.auth == 0
+ || session[sd->fd]->session_data == NULL || sd->packet_ver > MAX_PACKET_VER)
+ continue;
+
+ if (sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS))
+ continue;
+
+ if (type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m)
+ continue;
+
+ if ((type == PARTY_AREA || type == PARTY_AREA_WOS) &&
+ (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1))
+ continue;
+
+ 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 (!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_id) {
+ 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);
@@ -2585,8 +2585,6 @@ int clif_updatestatus(struct map_session_data *sd,int type)
break;
case SP_HP:
WFIFOL(fd,4)=sd->battle_status.hp;
- if (sd->status.party_id)
- clif_party_hp(sd);
if (battle_config.disp_hpmeter)
clif_hpmeter(sd);
break;
@@ -5860,26 +5858,26 @@ int clif_party_created(struct map_session_data *sd,int flag)
return 0;
}
-int clif_party_main_info(struct party *p, int fd)
+int clif_party_main_info(struct party_data *p, int fd)
{
struct map_session_data *sd;
int i;
unsigned char buf[96];
- for (i=0; i<MAX_PARTY && !p->member[i].leader; i++);
+ for (i=0; i<MAX_PARTY && !p->party.member[i].leader; i++);
if (i >= MAX_PARTY) return 0; //Should never happen...
- sd = p->member[i].sd;
+ sd = p->data[i].sd;
WBUFW(buf,0)=0x1e9;
- WBUFL(buf,2)= p->member[i].account_id;
+ WBUFL(buf,2)= p->party.member[i].account_id;
WBUFL(buf,6)= 0; //We don't know yet what this long is about.
WBUFW(buf,10)=sd?sd->bl.x:0;
WBUFW(buf,12)=sd?sd->bl.y:0;
- WBUFB(buf,14)=(p->member[i].online)?0:1; //This byte is also unconfirmed...
- memcpy(WBUFP(buf,15), p->name, NAME_LENGTH);
- memcpy(WBUFP(buf,39), p->member[i].name, NAME_LENGTH);
- memcpy(WBUFP(buf,63), mapindex_id2name(p->member[i].map), MAP_NAME_LENGTH);
- WBUFB(buf,79) = (p->item&1)?1:0;
- WBUFB(buf,80) = (p->item&2)?1:0;
+ WBUFB(buf,14)=(p->party.member[i].online)?0:1; //This byte is also unconfirmed...
+ memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
+ memcpy(WBUFP(buf,39), p->party.member[i].name, NAME_LENGTH);
+ memcpy(WBUFP(buf,63), mapindex_id2name(p->party.member[i].map), MAP_NAME_LENGTH);
+ WBUFB(buf,79) = (p->party.item&1)?1:0;
+ WBUFB(buf,80) = (p->party.item&2)?1:0;
if(fd>=0){
WFIFOHEAD(fd,packet_len_table[0x1e9]);
memcpy(WFIFOP(fd,0),buf,packet_len_table[0x1e9]);
@@ -5887,9 +5885,9 @@ int clif_party_main_info(struct party *p, int fd)
return 1;
}
if (!sd) {
- for (i=0; i<MAX_PARTY && !p->member[i].sd; i++)
+ for (i=0; i<MAX_PARTY && !p->data[i].sd; i++)
if (i >= MAX_PARTY) return 0; //Should never happen...
- sd=p->member[i].sd;
+ sd=p->data[i].sd;
}
clif_send(buf,packet_len_table[0x1e9],&sd->bl,PARTY);
return 1;
@@ -5918,7 +5916,7 @@ int clif_party_join_info(struct party *p, struct map_session_data *sd)
* パーティ情報送信
*------------------------------------------
*/
-int clif_party_info(struct party *p,int fd)
+int clif_party_info(struct party_data *p,int fd)
{
unsigned char buf[1024];
int i,c;
@@ -5927,18 +5925,18 @@ int clif_party_info(struct party *p,int fd)
nullpo_retr(0, p);
WBUFW(buf,0)=0xfb;
- memcpy(WBUFP(buf,4),p->name,NAME_LENGTH);
+ memcpy(WBUFP(buf,4),p->party.name,NAME_LENGTH);
for(i=c=0;i<MAX_PARTY;i++){
- struct party_member *m=&p->member[i];
- if(m->account_id>0){
- if(sd==NULL) sd=m->sd;
- WBUFL(buf,28+c*46)=m->account_id;
- memcpy(WBUFP(buf,28+c*46+ 4),m->name,NAME_LENGTH);
- memcpy(WBUFP(buf,28+c*46+28),mapindex_id2name(m->map),MAP_NAME_LENGTH);
- WBUFB(buf,28+c*46+44)=(m->leader)?0:1;
- WBUFB(buf,28+c*46+45)=(m->online)?0:1;
- c++;
- }
+ struct party_member *m=&p->party.member[i];
+ if(!m->account_id)
+ continue;
+ if(sd==NULL) sd=p->data[i].sd;
+ WBUFL(buf,28+c*46)=m->account_id;
+ memcpy(WBUFP(buf,28+c*46+ 4),m->name,NAME_LENGTH);
+ memcpy(WBUFP(buf,28+c*46+28),mapindex_id2name(m->map),MAP_NAME_LENGTH);
+ WBUFB(buf,28+c*46+44)=(m->leader)?0:1;
+ WBUFB(buf,28+c*46+45)=(m->online)?0:1;
+ c++;
}
WBUFW(buf,2)=28+c*46;
if(fd>=0){ // fdが設定されてるならそれに送る
@@ -5958,7 +5956,7 @@ int clif_party_info(struct party *p,int fd)
int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
{
int fd;
- struct party *p;
+ struct party_data *p;
nullpo_retr(0, sd);
nullpo_retr(0, tsd);
@@ -5971,7 +5969,7 @@ int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
WFIFOHEAD(fd,packet_len_table[0xfe]);
WFIFOW(fd,0)=0xfe;
WFIFOL(fd,2)=sd->status.account_id;
- memcpy(WFIFOP(fd,6),p->name,NAME_LENGTH);
+ memcpy(WFIFOP(fd,6),p->party.name,NAME_LENGTH);
WFIFOSET(fd,packet_len_table[0xfe]);
return 0;
}
@@ -6002,7 +6000,7 @@ int clif_party_inviteack(struct map_session_data *sd,char *nick,int flag)
* 0x100=一人にのみ送信
*------------------------------------------
*/
-int clif_party_option(struct party *p,struct map_session_data *sd,int flag)
+int clif_party_option(struct party_data *p,struct map_session_data *sd,int flag)
{
unsigned char buf[16];
@@ -6012,14 +6010,14 @@ int clif_party_option(struct party *p,struct map_session_data *sd,int flag)
// printf("clif_party_option: %d %d %d\n",p->exp,p->item,flag);
if(sd==NULL && flag==0){
int i;
- for(i=0;i<MAX_PARTY;i++)
- if((sd=map_id2sd(p->member[i].account_id))!=NULL)
- break;
+ for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
+ if (i < MAX_PARTY)
+ sd = p->data[i].sd;
}
if(sd==NULL)
return 0;
WBUFW(buf,0)=0x101;
- WBUFW(buf,2)=((flag&0x01)?2:p->exp);
+ WBUFW(buf,2)=((flag&0x01)?2:p->party.exp);
WBUFW(buf,4)=0; //NOTE: We don't know yet what this is for, it is NOT for item share rules, though. [Skotlex]
if(flag==0)
clif_send(buf,packet_len_table[0x101],&sd->bl,PARTY);
@@ -6034,7 +6032,7 @@ int clif_party_option(struct party *p,struct map_session_data *sd,int flag)
* パーティ脱退(脱退前に呼ぶこと)
*------------------------------------------
*/
-int clif_party_leaved(struct party *p,struct map_session_data *sd,int account_id,char *name,int flag)
+int clif_party_leaved(struct party_data *p,struct map_session_data *sd,int account_id,char *name,int flag)
{
unsigned char buf[64];
int i;
@@ -6047,11 +6045,12 @@ int clif_party_leaved(struct party *p,struct map_session_data *sd,int account_id
WBUFB(buf,30)=flag&0x0f;
if((flag&0xf0)==0){
- if(sd==NULL)
- for(i=0;i<MAX_PARTY;i++)
- if((sd=p->member[i].sd)!=NULL)
- break;
- if (sd!=NULL)
+ if(sd==NULL) {
+ for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
+ if (i < MAX_PARTY)
+ sd = p->data[i].sd;
+ }
+ if (sd)
clif_send(buf,packet_len_table[0x105],&sd->bl,PARTY);
} else if (sd!=NULL) {
WFIFOHEAD(sd->fd,packet_len_table[0x105]);
@@ -6064,19 +6063,17 @@ int clif_party_leaved(struct party *p,struct map_session_data *sd,int account_id
* パーティメッセージ送信
*------------------------------------------
*/
-int clif_party_message(struct party *p,int account_id,char *mes,int len)
+int clif_party_message(struct party_data *p,int account_id,char *mes,int len)
{
struct map_session_data *sd;
int i;
nullpo_retr(0, p);
- for(i=0;i<MAX_PARTY;i++){
- if((sd=p->member[i].sd)!=NULL)
- break;
- }
- if(sd!=NULL){
+ for(i=0; i < MAX_PARTY && !p->data[i].sd;i++);
+ if(i < MAX_PARTY){
unsigned char buf[1024];
+ sd = p->data[i].sd;
WBUFW(buf,0)=0x109;
WBUFW(buf,2)=len+8;
WBUFL(buf,4)=account_id;
@@ -7755,7 +7752,7 @@ int clif_charnameack (int fd, struct block_list *bl)
case BL_PC:
{
struct map_session_data *ssd = (struct map_session_data *)bl;
- struct party *p = NULL;
+ struct party_data *p = NULL;
struct guild *g = NULL;
//Requesting your own "shadow" name. [Skotlex]
@@ -7779,7 +7776,7 @@ int clif_charnameack (int fd, struct block_list *bl)
WBUFW(buf, 0) = cmd = 0x195;
if (p)
- memcpy(WBUFP(buf,30), p->name, NAME_LENGTH);
+ memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
else
WBUFB(buf,30) = 0;
@@ -7869,7 +7866,7 @@ int clif_charnameupdate (struct map_session_data *ssd)
{
unsigned char buf[103];
int cmd = 0x195;
- struct party *p = NULL;
+ struct party_data *p = NULL;
struct guild *g = NULL;
nullpo_retr(0, ssd);
@@ -7889,7 +7886,7 @@ int clif_charnameupdate (struct map_session_data *ssd)
g = guild_search(ssd->status.guild_id);
if (p)
- memcpy(WBUFP(buf,30), p->name, NAME_LENGTH);
+ memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
else
WBUFB(buf,30) = 0;