Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: src/char/int_party.c
- ===================================================================
- --- src/char/int_party.c (revisão 16496)
- +++ src/char/int_party.c (cópia de trabalho)
- @@ -106,7 +106,7 @@
- if (p->party.exp && !party_check_exp_share(p)) {
- p->party.exp = 0; //Set off even share.
- - mapif_party_optionchanged(0, &p->party, 0, 0);
- + mapif_party_optionchanged(0, &p->party, 0, 0);// FIXME notifications should be handled outside since this can be called on parties that aren't available yet [flaviojs]
- }
- return;
- }
- @@ -326,26 +326,18 @@
- //-------------------------------------------------------------------
- // map server‚Ö‚Ì’ÊM
- -// ƒp[ƒeƒB쬉”Û
- -int mapif_party_created(int fd,int account_id,int char_id,struct party *p)
- +/// Party creation notification.
- +/// @param result 0 on success, 1 on failure
- +static void mapif_party_created(int fd, int account_id, int char_id, int result, int party_id, const char* name)
- {
- WFIFOHEAD(fd, 39);
- - WFIFOW(fd,0)=0x3820;
- - WFIFOL(fd,2)=account_id;
- - WFIFOL(fd,6)=char_id;
- - if(p!=NULL){
- - WFIFOB(fd,10)=0;
- - WFIFOL(fd,11)=p->party_id;
- - memcpy(WFIFOP(fd,15),p->name,NAME_LENGTH);
- - ShowInfo("int_party: Party created (%d - %s)\n",p->party_id,p->name);
- - }else{
- - WFIFOB(fd,10)=1;
- - WFIFOL(fd,11)=0;
- - memset(WFIFOP(fd,15),0,NAME_LENGTH);
- - }
- + WFIFOW(fd,0) = 0x3820;
- + WFIFOL(fd,2) = account_id;
- + WFIFOL(fd,6) = char_id;
- + WFIFOB(fd,10) = result;
- + WFIFOL(fd,11) = party_id;
- + safestrncpy((char*)WFIFOP(fd,15), name, NAME_LENGTH);
- WFIFOSET(fd,39);
- -
- - return 0;
- }
- // ƒp[ƒeƒBî•ñŒ©‚‚©‚炸
- @@ -459,27 +451,27 @@
- // map server‚©‚ç‚Ì’ÊM
- -// Create Party
- -int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader)
- +/// Create a party.
- +static void mapif_parse_CreateParty(int fd, char* name, int item, int item2, struct party_member* leader)
- {
- struct party_data *p;
- int i;
- if( (p=search_partyname(name))!=NULL){
- - mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
- - return 0;
- + mapif_party_created(fd, leader->account_id, leader->char_id, 1, 0, "");
- + return;
- }
- // Check Authorised letters/symbols in the name of the character
- if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
- for (i = 0; i < NAME_LENGTH && name[i]; i++)
- if (strchr(char_name_letters, name[i]) == NULL) {
- - mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
- - return 0;
- + mapif_party_created(fd, leader->account_id, leader->char_id, 1, 0, "");
- + return;
- }
- } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
- for (i = 0; i < NAME_LENGTH && name[i]; i++)
- if (strchr(char_name_letters, name[i]) != NULL) {
- - mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
- - return 0;
- + mapif_party_created(fd, leader->account_id, leader->char_id, 1, 0, "");
- + return;
- }
- }
- @@ -499,13 +491,11 @@
- int_party_calc_state(p);
- idb_put(party_db_, p->party.party_id, p);
- mapif_party_info(fd, &p->party, 0);
- - mapif_party_created(fd,leader->account_id,leader->char_id,&p->party);
- + mapif_party_created(fd, leader->account_id, leader->char_id, 0, p->party.party_id, p->party.name);
- } else { //Failed to create party.
- aFree(p);
- - mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
- + mapif_party_created(fd, leader->account_id, leader->char_id, 1, 0, "");
- }
- -
- - return 0;
- }
- // ƒp[ƒeƒBî•ñ—v‹
- static void mapif_parse_PartyInfo(int fd, int party_id, int char_id)
- Index: src/map/clif.c
- ===================================================================
- --- src/map/clif.c (revisão 16496)
- +++ src/map/clif.c (cópia de trabalho)
- @@ -6196,6 +6196,10 @@
- /// Adds new member to a party.
- +/// Other behaviours:
- +/// updates item share options without a message
- +/// replaces member if the charname matches
- +/// ignores position fields // TODO check on different clients [flaviojs]
- /// 0104 <account id>.L <role>.L <x>.W <y>.W <state>.B <party name>.24B <char name>.24B <map name>.16B (ZC_ADD_MEMBER_TO_GROUP)
- /// 01e9 <account id>.L <role>.L <x>.W <y>.W <state>.B <party name>.24B <char name>.24B <map name>.16B <item pickup rule>.B <item share rule>.B (ZC_ADD_MEMBER_TO_GROUP2)
- /// role:
- @@ -6204,31 +6208,35 @@
- /// state:
- /// 0 = connected
- /// 1 = disconnected
- -void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
- +void clif_party_member_info(struct party_data *p, int member_id, send_target type)
- {
- unsigned char buf[81];
- - int i;
- + struct map_session_data* sd;
- + struct party_member* m;
- - if (!sd) { //Pick any party member (this call is used when changing item share rules)
- - ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd != 0 );
- - } else {
- - ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd == sd );
- - }
- - if (i >= MAX_PARTY) return; //Should never happen...
- - sd = p->data[i].sd;
- + nullpo_retv(p);
- + if( member_id < 0 || member_id >= MAX_PARTY )
- + return;// out of range
- + m = &p->party.member[member_id];
- + sd = p->data[member_id].sd;
- + if( sd == NULL && type != SELF )
- + sd = party_getavailablesd(p);// can use any party member
- + if( sd == NULL )
- + return;// not online
- +
- WBUFW(buf, 0) = 0x1e9;
- - WBUFL(buf, 2) = sd->status.account_id;
- - WBUFL(buf, 6) = (p->party.member[i].leader)?0:1;
- - WBUFW(buf,10) = sd->bl.x;
- - WBUFW(buf,12) = sd->bl.y;
- - WBUFB(buf,14) = (p->party.member[i].online)?0:1;
- + WBUFL(buf, 2) = m->account_id;
- + WBUFL(buf, 6) = ( m->leader ) ? 0 : 1;// role: 0-leader 1-member
- + WBUFW(buf,10) = p->data[member_id].x;
- + WBUFW(buf,12) = p->data[member_id].y;
- + WBUFB(buf,14) = ( m->online ) ? 0 : 1;// state: 0-online 1-offline
- memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
- - memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
- - mapindex_getmapname_ext(map[sd->bl.m].name, (char*)WBUFP(buf,63));
- + memcpy(WBUFP(buf,39), m->name, NAME_LENGTH);
- + mapindex_getmapname_ext(map[m->map].name, (char*)WBUFP(buf,63));
- WBUFB(buf,79) = (p->party.item&1)?1:0;
- WBUFB(buf,80) = (p->party.item&2)?1:0;
- - clif_send(buf,packet_len(0x1e9),&sd->bl,PARTY);
- + clif_send(buf,packet_len(0x1e9),&sd->bl,type);
- }
- @@ -6363,18 +6371,17 @@
- /// Updates party settings.
- +/// Other behaviour:
- +/// notifies the user about the current options
- /// 0101 <exp option>.L (ZC_GROUPINFO_CHANGE)
- /// 07d8 <exp option>.L <item pick rule>.B <item share rule>.B (ZC_REQ_GROUPINFO_CHANGE_V2)
- /// exp option:
- /// 0 = exp sharing disabled
- /// 1 = exp sharing enabled
- /// 2 = cannot change exp sharing
- -///
- -/// flag:
- -/// 0 = send to party
- -/// 1 = send to sd
- -void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag)
- +void clif_party_option(struct party_data* p, int member_id, send_target type)
- {
- + struct map_session_data* sd;
- unsigned char buf[16];
- #if PACKETVER < 20090603
- const int cmd = 0x101;
- @@ -6384,26 +6391,47 @@
- nullpo_retv(p);
- - if(!sd && flag==0){
- - int i;
- - for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
- - if (i < MAX_PARTY)
- - sd = p->data[i].sd;
- - }
- - if(!sd) return;
- + if( member_id < 0 || member_id >= MAX_PARTY )
- + return;// out of range
- + sd = p->data[member_id].sd;
- + if( sd == NULL && type != SELF )
- + sd = party_getavailablesd(p);// can use any party member
- + if( sd == NULL )
- + return;// not online
- +
- WBUFW(buf,0)=cmd;
- - WBUFL(buf,2)=((flag&0x01)?2:p->party.exp);
- + WBUFL(buf,2)=p->party.exp;
- #if PACKETVER >= 20090603
- WBUFB(buf,6)=(p->party.item&1)?1:0;
- WBUFB(buf,7)=(p->party.item&2)?1:0;
- +#else
- + // item changes are not notified in older clients
- + clif_party_member_info(p, member_id, type);
- #endif
- - if(flag==0)
- - clif_send(buf,packet_len(cmd),&sd->bl,PARTY);
- - else
- - clif_send(buf,packet_len(cmd),&sd->bl,SELF);
- + clif_send(buf,packet_len(cmd),&sd->bl,type);
- }
- +/// Notify the user that it cannot change exp sharing.
- +/// 0101 <exp option>.L (ZC_GROUPINFO_CHANGE)
- +/// exp option:
- +/// 0 = exp sharing disabled
- +/// 1 = exp sharing enabled
- +/// 2 = cannot change exp sharing
- +void clif_party_option_failexp(struct map_session_data* sd)
- +{
- + unsigned char buf[16];
- +
- + if( sd == NULL )
- + return;
- +
- + WBUFW(buf,0) = 0x101;
- + WBUFL(buf,2) = 2;// cannot change exp sharing
- +
- + clif_send(buf,packet_len(0x101),&sd->bl,SELF);
- +}
- +
- +
- /// 0105 <account id>.L <char name>.24B <result>.B (ZC_DELETE_MEMBER_FROM_GROUP).
- /// result:
- /// 0 = leave
- Index: src/map/clif.h
- ===================================================================
- --- src/map/clif.h (revisão 16496)
- +++ src/map/clif.h (cópia de trabalho)
- @@ -494,11 +494,12 @@
- // party
- void clif_party_created(struct map_session_data *sd,int result);
- -void clif_party_member_info(struct party_data *p, struct map_session_data *sd);
- +void clif_party_member_info(struct party_data *p, int member_id, send_target type);
- void clif_party_info(struct party_data* p, struct map_session_data *sd);
- void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd);
- void clif_party_inviteack(struct map_session_data* sd, const char* nick, int result);
- -void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag);
- +void clif_party_option(struct party_data* p, int member_id, send_target type);
- +void clif_party_option_failexp(struct map_session_data* sd);
- void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int account_id, const char* name, int flag);
- void clif_party_message(struct party_data* p, int account_id, const char* mes, int len);
- void clif_party_xy(struct map_session_data *sd);
- Index: src/map/intif.c
- ===================================================================
- --- src/map/intif.c (revisão 16496)
- +++ src/map/intif.c (cópia de trabalho)
- @@ -52,7 +52,9 @@
- //-----------------------------------------------------------------
- // inter server‚Ö‚Ì‘—M
- -int CheckForCharServer(void)
- +
- +/// Returns true if not connected to the char-server.
- +bool CheckForCharServer(void)
- {
- return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL);
- }
- @@ -386,22 +388,23 @@
- return 0;
- }
- -// ƒp[ƒeƒB쬗v‹
- -int intif_create_party(struct party_member *member,char *name,int item,int item2)
- +/// Create a party.
- +/// Returns true if the request is sent.
- +bool intif_create_party(struct party_member* member, const char* name, int item, int item2)
- {
- if (CheckForCharServer())
- - return 0;
- - nullpo_ret(member);
- + return false;
- + nullpo_retr(false, member);
- WFIFOHEAD(inter_fd,64);
- WFIFOW(inter_fd,0) = 0x3020;
- WFIFOW(inter_fd,2) = 30+sizeof(struct party_member);
- memcpy(WFIFOP(inter_fd,4),name, NAME_LENGTH);
- - WFIFOB(inter_fd,28)= item;
- - WFIFOB(inter_fd,29)= item2;
- + WFIFOB(inter_fd,28) = item;
- + WFIFOB(inter_fd,29) = item2;
- memcpy(WFIFOP(inter_fd,30), member, sizeof(struct party_member));
- WFIFOSET(inter_fd,WFIFOW(inter_fd, 2));
- - return 0;
- + return true;
- }
- // ƒp[ƒeƒBî•ñ—v‹
- int intif_request_partyinfo(int party_id, int char_id)
- @@ -1023,12 +1026,12 @@
- return 0;
- }
- -// ƒp[ƒeƒB쬉”Û
- +/// Party creation notification.
- int intif_parse_PartyCreated(int fd)
- {
- if(battle_config.etc_log)
- ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2));
- - party_created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15));
- + party_created(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOB(fd,10), RFIFOL(fd,11), (const char *)RFIFOP(fd,15));
- return 0;
- }
- // ƒp[ƒeƒBî•ñ
- Index: src/map/intif.h
- ===================================================================
- --- src/map/intif.h (revisão 16496)
- +++ src/map/intif.h (cópia de trabalho)
- @@ -31,7 +31,7 @@
- int intif_send_guild_storage(int account_id, struct guild_storage *gstor);
- -int intif_create_party(struct party_member *member,char *name,int item,int item2);
- +bool intif_create_party(struct party_member* member, const char* name, int item, int item2);
- int intif_request_partyinfo(int party_id, int char_id);
- int intif_party_addmember(int party_id,struct party_member *member);
- @@ -107,6 +107,6 @@
- /* @accinfo */
- void intif_request_accinfo( int u_fd, int aid, int group_id, char* query );
- -int CheckForCharServer(void);
- +bool CheckForCharServer(void);
- #endif /* _INTIF_H_ */
- Index: src/map/party.c
- ===================================================================
- --- src/map/party.c (revisão 16496)
- +++ src/map/party.c (cópia de trabalho)
- @@ -143,7 +143,9 @@
- return p;
- }
- -int party_create(struct map_session_data *sd,char *name,int item,int item2)
- +/// Request the creation of a party.
- +/// Returns true if the request was sent.
- +bool party_create(struct map_session_data* sd, const char* name, int item, int item2)
- {
- struct party_member leader;
- char tname[NAME_LENGTH];
- @@ -153,25 +155,24 @@
- if( !tname[0] )
- {// empty name
- - return 0;
- + return false;
- }
- if( sd->status.party_id > 0 || sd->party_joining || sd->party_creating )
- {// already associated with a party
- clif_party_created(sd,2);
- - return 0;
- + return false;
- }
- - sd->party_creating = true;
- -
- party_fill_member(&leader, sd, 1);
- - intif_create_party(&leader,name,item,item2);
- - return 0;
- + sd->party_creating = intif_create_party(&leader,name,item,item2);
- + return sd->party_creating;
- }
- -void party_created(int account_id,int char_id,int fail,int party_id,char *name)
- +/// Party creation notification.
- +void party_created(int account_id, int char_id, int fail, int party_id, const char* name)
- {
- struct map_session_data *sd;
- sd=map_id2sd(account_id);
- @@ -316,8 +317,8 @@
- if( sd == NULL )
- continue;// not online
- clif_charnameupdate(sd); //Update other people's display. [Skotlex]
- - clif_party_member_info(p,sd);
- - clif_party_option(p,sd,0x100);
- + clif_party_member_info(p, member_id, PARTY);
- + clif_party_option(p, member_id, SELF);
- clif_party_info(p,NULL);
- if( p->instance_id != 0 )
- clif_instance_join(sd->fd, p->instance_id);
- @@ -480,8 +481,8 @@
- sd->status.party_id = party_id;
- - clif_party_member_info(p,sd);
- - clif_party_option(p,sd,0x100);
- + clif_party_member_info(p, party_getmemberid(p,sd), PARTY);
- + clif_party_option(p, party_getmemberid(p,sd), SELF);
- clif_party_info(p,sd);
- if( sd2 != NULL )
- @@ -607,6 +608,7 @@
- return 0;
- }
- +/// Request the charserver to change party options.
- int party_changeoption(struct map_session_data *sd,int exp,int item)
- {
- nullpo_ret(sd);
- @@ -617,22 +619,26 @@
- return 0;
- }
- -int party_optionchanged(int party_id,int account_id,int exp,int item,int flag)
- +/// Reply from charserver about changed party options.
- +/// flag bitfield:
- +/// &0x01 - exp change denied
- +/// &0x10 - item change denied
- +void party_optionchanged(int party_id, int account_id, int exp, int item, int flag)
- {
- struct party_data *p;
- struct map_session_data *sd=map_id2sd(account_id);
- if( (p=party_search(party_id))==NULL)
- - return 0;
- + return;
- //Flag&1: Exp change denied. Flag&2: Item change denied.
- if(!(flag&0x01) && p->party.exp != exp)
- p->party.exp=exp;
- - if(!(flag&0x10) && p->party.item != item) {
- + if(!(flag&0x10) && p->party.item != item)
- p->party.item=item;
- - }
- - clif_party_option(p,sd,flag);
- - return 0;
- + if( (flag&0x01) )
- + clif_party_option_failexp(sd);
- + clif_party_option(p, party_getmemberid(p,sd), PARTY);
- }
- bool party_changeleader(struct map_session_data *sd, struct map_session_data *tsd)
- @@ -733,9 +739,9 @@
- if(sd->state.connect_new) {
- //Note that this works because this function is invoked before connect_new is cleared.
- - clif_party_option(p,sd,0x100);
- + clif_party_option(p, party_getmemberid(p,sd), SELF);
- clif_party_info(p,sd);
- - clif_party_member_info(p,sd);
- + clif_party_member_info(p, party_getmemberid(p,sd), PARTY);
- }
- if (sd->fd) { // synchronize minimap positions with the rest of the party
- Index: src/map/party.h
- ===================================================================
- --- src/map/party.h (revisão 16496)
- +++ src/map/party.h (cópia de trabalho)
- @@ -54,8 +54,8 @@
- int party_getmemberid(struct party_data* p, struct map_session_data* sd);
- struct map_session_data* party_getavailablesd(struct party_data *p);
- -int party_create(struct map_session_data *sd,char *name, int item, int item2);
- -void party_created(int account_id,int char_id,int fail,int party_id,char *name);
- +bool party_create(struct map_session_data* sd, const char* name, int item, int item2);
- +void party_created(int account_id, int char_id, int fail, int party_id, const char* name);
- int party_request_info(int party_id, int char_id);
- int party_invite(struct map_session_data *sd,struct map_session_data *tsd);
- void party_member_joined(struct map_session_data *sd);
- @@ -68,7 +68,7 @@
- int party_recv_info(struct party* sp, int char_id);
- int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv);
- int party_broken(int party_id);
- -int party_optionchanged(int party_id,int account_id,int exp,int item,int flag);
- +void party_optionchanged(int party_id, int account_id, int exp, int item, int flag);
- int party_changeoption(struct map_session_data *sd,int exp,int item);
- bool party_changeleader(struct map_session_data *sd, struct map_session_data *t_sd);
- void party_send_movemap(struct map_session_data *sd);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement