diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-03-08 23:03:06 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-03-08 23:03:06 +0000 |
commit | 133d6e1686771a4acda5dc421499199528196e0c (patch) | |
tree | 24e530c7a9256f1845685c1799b14cd6c03d4cc5 | |
parent | a0046ed8734160aaaf8ce8afbebee81eb537cbbf (diff) | |
download | hercules-133d6e1686771a4acda5dc421499199528196e0c.tar.gz hercules-133d6e1686771a4acda5dc421499199528196e0c.tar.bz2 hercules-133d6e1686771a4acda5dc421499199528196e0c.tar.xz hercules-133d6e1686771a4acda5dc421499199528196e0c.zip |
Corrected a problem where a party invite acknowledgement would not be sent (bugreport:1091).
There is still the unresolved issue where newly added party members will not display their party correctly.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12328 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | src/char/int_party.c | 45 | ||||
-rw-r--r-- | src/char_sql/int_party.c | 49 | ||||
-rw-r--r-- | src/map/clif.c | 36 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/party.c | 52 | ||||
-rw-r--r-- | src/map/party.h | 4 |
6 files changed, 101 insertions, 87 deletions
diff --git a/src/char/int_party.c b/src/char/int_party.c index 50d6b0d6a..64facec47 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -519,36 +519,39 @@ int mapif_parse_PartyInfo(int fd, int party_id) { return 0; } -// パ?ティ追加要求 -int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member) { +// パーティ追加要求 +int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member) +{ struct party_data *p; int i; p = idb_get(party_db, party_id); - if (p == NULL || p->size == MAX_PARTY) { + if( p == NULL || p->size == MAX_PARTY ) { mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); return 0; } - for(i = 0; i < MAX_PARTY; i++) { - if (p->party.member[i].account_id == 0) { - memcpy(&p->party.member[i], member, sizeof(struct party_member)); - p->party.member[i].leader = 0; - if (p->party.member[i].online) p->party.count++; - p->size++; - if (p->size == 3) //Check family state. - int_party_calc_state(p); - else //Check even share range. - if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) { - if (p->family) p->family = 0; //Family state broken. - int_party_check_lv(p); - } - mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 0); - mapif_party_info(-1, &p->party); - return 0; - } + ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == 0 ); + if( i == MAX_PARTY ) + {// Party full + mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); + return 0; } - mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); + + memcpy(&p->party.member[i], member, sizeof(struct party_member)); + p->party.member[i].leader = 0; + if (p->party.member[i].online) p->party.count++; + p->size++; + if (p->size == 3) //Check family state. + int_party_calc_state(p); + else //Check even share range. + if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) { + if (p->family) p->family = 0; //Family state broken. + int_party_check_lv(p); + } + + mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 0); + mapif_party_info(-1, &p->party); return 0; } diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index cff17c5b5..a51b8def0 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -535,42 +535,43 @@ int mapif_parse_PartyInfo(int fd,int party_id) return 0; } // パーティ追加要求 -int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member) { +int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member) +{ struct party_data *p; int i; p = inter_party_fromsql(party_id); + if( p == NULL || p->size == MAX_PARTY ) { + mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); + return 0; + } - if(!p || p->size == MAX_PARTY){ - mapif_party_memberadded(fd,party_id,member->account_id,member->char_id,1); + ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == 0 ); + if( i == MAX_PARTY ) + {// Party full + mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); return 0; } - for(i=0;i<MAX_PARTY;i++){ - if(p->party.member[i].account_id) - continue; + memcpy(&p->party.member[i], member, sizeof(struct party_member)); + p->party.member[i].leader = 0; + if (p->party.member[i].online) p->party.count++; + p->size++; + if (p->size == 3) //Check family state. + int_party_calc_state(p); + else //Check even share range. + if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) { + if (p->family) p->family = 0; //Family state broken. + int_party_check_lv(p); + } - memcpy(&p->party.member[i], member, sizeof(struct party_member)); - p->party.member[i].leader=0; - if (p->party.member[i].online) p->party.count++; - p->size++; - if (p->size == 3) //Check family state. - int_party_calc_state(p); - else //Check even share range. - if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) { - if (p->family) p->family = 0; //Family state broken. - int_party_check_lv(p); - } + mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 0); + mapif_party_info(-1, &p->party); + inter_party_tosql(&p->party, PS_ADDMEMBER, i); - mapif_party_memberadded(fd,party_id,member->account_id,member->char_id,0); - mapif_party_info(-1,&p->party); - inter_party_tosql(&p->party, PS_ADDMEMBER, i); - return 0; - } - //Party full - mapif_party_memberadded(fd,party_id,member->account_id,member->char_id,1); return 0; } + // パーティー設定変更要求 int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item) { diff --git a/src/map/clif.c b/src/map/clif.c index c4b0134a9..551155ea3 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5411,19 +5411,17 @@ int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd) * 3 -> party is full * 4 -> char of the same account already joined the party *------------------------------------------*/ -int clif_party_inviteack(struct map_session_data* sd, const char* nick, int flag) +void clif_party_inviteack(struct map_session_data* sd, const char* nick, int flag) { int fd; - - nullpo_retr(0, sd); - + nullpo_retv(sd); fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xfd)); - WFIFOW(fd,0)=0xfd; - memcpy(WFIFOP(fd,2),nick,NAME_LENGTH); - WFIFOB(fd,26)=flag; + WFIFOW(fd,0) = 0xfd; + safestrncpy((char*)WFIFOP(fd,2),nick,NAME_LENGTH); + WFIFOB(fd,26) = flag; WFIFOSET(fd,packet_len(0xfd)); - return 0; } /*========================================== @@ -9818,27 +9816,35 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) party_invite(sd, t_sd); } + /*========================================== - * パーティ勧誘返答 + * Party invitation reply + * S 00ff <account ID>.L <flag>.L + * S 02c7 <account ID>.L <flag>.B + * flag: 0-reject, 1-accept *------------------------------------------*/ void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) { - if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 5){ - party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6)); - } else { + if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 5 ) + { party_reply_invite(sd,RFIFOL(fd,2),-1); clif_skill_fail(sd,1,0,4); + return; } + + party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6)); } void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd) { - if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 5){ - party_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6)); - } else { + if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 5 ) + { party_reply_invite(sd,RFIFOL(fd,2),-1); clif_skill_fail(sd,1,0,4); + return; } + + party_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6)); } /*========================================== diff --git a/src/map/clif.h b/src/map/clif.h index 58c088dad..adb12ffc1 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -281,7 +281,7 @@ int clif_party_created(struct map_session_data *sd,int result); int clif_party_member_info(struct party_data *p, struct map_session_data *sd); int clif_party_info(struct party_data *p, struct map_session_data *sd); int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd); -int clif_party_inviteack(struct map_session_data* sd, const char* nick, int flag); +void clif_party_inviteack(struct map_session_data* sd, const char* nick, int flag); int clif_party_option(struct party_data *p,struct map_session_data *sd,int flag); int clif_party_leaved(struct party_data* p, struct map_session_data* sd, int account_id, const char* name, int flag); int clif_party_message(struct party_data* p, int account_id, const char* mes, int len); diff --git a/src/map/party.c b/src/map/party.c index b8cd03811..7707ddca3 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -122,7 +122,7 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2) } -int party_created(int account_id,int char_id,int fail,int party_id,char *name) +void party_created(int account_id,int char_id,int fail,int party_id,char *name) { struct map_session_data *sd; sd=map_id2sd(account_id); @@ -131,17 +131,16 @@ int party_created(int account_id,int char_id,int fail,int party_id,char *name) { //Character logged off before creation ack? if (!fail) //break up party since player could not be added to it. intif_party_leave(party_id,account_id,char_id); - return 0; + return; } - if(fail){ - clif_party_created(sd,1); - return 0; // "party name already exists" + if( !fail ) { + sd->status.party_id = party_id; + clif_party_created(sd,0); //Success message + //We don't do any further work here because the char-server sends a party info packet right after creating the party. + } else { + clif_party_created(sd,1); // "party name already exists" } - sd->status.party_id=party_id; - clif_party_created(sd,0); //Success message - //We don't do any further work here because the char-server sends a party info packet right after creating the party. - return 1; } int party_request_info(int party_id) @@ -328,22 +327,23 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd) return 1; } -int party_reply_invite(struct map_session_data *sd,int account_id,int flag) +void party_reply_invite(struct map_session_data *sd,int account_id,int flag) { struct map_session_data *tsd= map_id2sd(account_id); struct party_member member; - if(flag==1){ + if( flag == 1 ) + {// accepted party_fill_member(&member, sd); intif_party_addmember(sd->party_invite, &member); - return 0; } - sd->party_invite=0; - sd->party_invite_account=0; - if(tsd==NULL) - return 0; - clif_party_inviteack(tsd,sd->status.name,1); - return 1; + else + {// rejected or failure + sd->party_invite = 0; + sd->party_invite_account = 0; + if( tsd != NULL ) + clif_party_inviteack(tsd,sd->status.name,1); + } } //Invoked when a player joins: @@ -367,10 +367,12 @@ void party_member_joined(struct map_session_data *sd) } /// Invoked (from char-server) when a new member is added to the party. +/// flag: 0-success, 1-failure int party_member_added(int party_id,int account_id,int char_id, int flag) { struct map_session_data *sd = map_id2sd(account_id),*sd2; struct party_data *p = party_search(party_id); + int invite_aid; int i; if(sd == NULL || sd->status.char_id != char_id){ @@ -378,8 +380,10 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) intif_party_leave(party_id,account_id,char_id); return 0; } - sd->party_invite=0; - sd->party_invite_account=0; + + invite_aid = sd->party_invite_account; + sd->party_invite = 0; + sd->party_invite_account = 0; if (!p) { ShowError("party_member_added: party %d not found.\n",party_id); @@ -387,8 +391,8 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) return 0; } - if(!flag) { - sd->status.party_id=party_id; + if( flag == 0 ) { + sd->status.party_id = party_id; party_check_conflict(sd); clif_party_option(p,sd,0x100); clif_party_info(p,sd); @@ -404,8 +408,8 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) clif_charnameupdate(sd); //Update char name's display [Skotlex] } - sd2=map_id2sd(sd->party_invite_account); - if (sd2) + sd2 = map_id2sd(invite_aid); + if( sd2 != NULL ) clif_party_inviteack(sd2,sd->status.name,flag?2:1); return 0; } diff --git a/src/map/party.h b/src/map/party.h index b04797fb1..54f55a6c2 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -21,7 +21,7 @@ struct party_data* party_search(int party_id); struct party_data* party_searchname(const char* str); int party_create(struct map_session_data *sd,char *name, int item, int item2); -int party_created(int account_id,int char_id,int fail,int party_id,char *name); +void party_created(int account_id,int char_id,int fail,int party_id,char *name); int party_request_info(int party_id); int party_invite(struct map_session_data *sd,struct map_session_data *tsd); void party_member_joined(struct map_session_data *sd); @@ -29,7 +29,7 @@ int party_member_added(int party_id,int account_id,int char_id,int flag); int party_leave(struct map_session_data *sd); int party_removemember(struct map_session_data *sd,int account_id,char *name); int party_member_leaved(int party_id,int account_id,int char_id); -int party_reply_invite(struct map_session_data *sd,int account_id,int flag); +void party_reply_invite(struct map_session_data *sd,int account_id,int flag); int party_recv_noinfo(int party_id); int party_recv_info(struct party *sp); int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv); |