From 6dcb99e42257de276814d3fe42a19c8f85e776d2 Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 6 Jul 2006 23:39:24 +0000 Subject: - Modified the party_data structure on the map server to remove some redundant data. Added a party_data structure on the char-server to hold a more complete set of information about parties. Added to the party_member structure the class of each member so that the map server can do the appropiate checks even if the character is on another mapserver/offline. Due to the format changes in the party structure, txt servers will have to wipe their party file... (sql save format has not been changed) - Added function char_family to check if there's a family state given the three character ids, instead of doing individual checks all the time. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7553 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/intif.c | 32 ++++++++++++----------------- src/map/intif.h | 5 +++-- src/map/party.c | 64 ++++++++++++++++++++++++++++++++++++++++++--------------- src/map/skill.c | 2 +- 4 files changed, 65 insertions(+), 38 deletions(-) (limited to 'src/map') diff --git a/src/map/intif.c b/src/map/intif.c index 09e83b831..ef616e638 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -371,23 +371,20 @@ int intif_send_guild_storage(int account_id,struct guild_storage *gstor) } // パーティ作成要求 -int intif_create_party(struct map_session_data *sd,char *name,int item,int item2) +int intif_create_party(struct party_member *member,char *name,int item,int item2) { if (CheckForCharServer()) return 0; - nullpo_retr(0, sd); + nullpo_retr(0, member); WFIFOHEAD(inter_fd,64); WFIFOW(inter_fd,0) = 0x3020; - WFIFOL(inter_fd,2) = sd->status.account_id; - WFIFOL(inter_fd,6) = sd->status.char_id; - memcpy(WFIFOP(inter_fd,10),name, NAME_LENGTH); - memcpy(WFIFOP(inter_fd,34),sd->status.name,NAME_LENGTH); - WFIFOW(inter_fd,58) = sd->mapindex; - WFIFOW(inter_fd,60)= sd->status.base_level; - WFIFOB(inter_fd,62)= item; - WFIFOB(inter_fd,63)= item2; - WFIFOSET(inter_fd,64); + WFIFOW(inter_fd,2) = 24+2+sizeof(struct party_member); + memcpy(WFIFOP(inter_fd,4),name, NAME_LENGTH); + 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; } // パーティ情報要求 @@ -404,20 +401,17 @@ int intif_request_partyinfo(int party_id) return 0; } // パーティ追加要求 -int intif_party_addmember(int party_id,struct map_session_data *sd) +int intif_party_addmember(int party_id,struct party_member *member) { if (CheckForCharServer()) return 0; WFIFOHEAD(inter_fd,42); WFIFOW(inter_fd,0)=0x3022; - WFIFOL(inter_fd,2)=party_id; - WFIFOL(inter_fd,6)=sd->status.account_id; - WFIFOL(inter_fd,10)=sd->status.char_id; - memcpy(WFIFOP(inter_fd,14),sd->status.name,NAME_LENGTH); - WFIFOW(inter_fd,38) = sd->mapindex; - WFIFOW(inter_fd,40)=sd->status.base_level; - WFIFOSET(inter_fd,42); + WFIFOW(inter_fd,2)=8+sizeof(struct party_member); + WFIFOL(inter_fd,4)=party_id; + memcpy(WFIFOP(inter_fd,8),member,sizeof(struct party_member)); + WFIFOSET(inter_fd,WFIFOW(inter_fd, 2)); return 1; } // パーティ設定変更 diff --git a/src/map/intif.h b/src/map/intif.h index 43a6c17a2..38a2cace7 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -21,9 +21,10 @@ int intif_request_guild_storage(int account_id, int guild_id); int intif_send_guild_storage(int account_id, struct guild_storage *gstor); -int intif_create_party(struct map_session_data *sd,char *name,int item,int item2); +int intif_create_party(struct party_member *member,char *name,int item,int item2); int intif_request_partyinfo(int party_id); -int intif_party_addmember(int party_id, struct map_session_data *sd); + +int intif_party_addmember(int party_id,struct party_member *member); int intif_party_changeoption(int party_id, int account_id, int exp, int item); int intif_party_leave(int party_id,int account_id, int char_id); int intif_party_changemap(struct map_session_data *sd, int online); diff --git a/src/map/party.c b/src/map/party.c index 4afb69411..24f29a603 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -28,6 +28,23 @@ static struct dbt* party_db; static struct party_data* party_cache = NULL; //party in cache for skipping consecutive lookups. [Skotlex] int party_share_level = 10; int party_send_xy_timer(int tid,unsigned int tick,int id,int data); + +/*========================================== + * Fills the given party_member structure according to the sd provided. + * Used when creating/adding people to a party. [Skotlex] + *------------------------------------------ + */ +static void party_fill_member(struct party_member *member, struct map_session_data *sd) { + member->account_id = sd->status.account_id; + member->char_id = sd->status.char_id; + memcpy(member->name,sd->status.name,NAME_LENGTH); + member->class_ = sd->status.class_; + member->map = sd->mapindex; + member->lv = sd->status.base_level; + member->online = 1; + member->leader = 0; +} + /*========================================== * 終了 *------------------------------------------ @@ -74,12 +91,18 @@ struct party_data* party_searchname(char *str) int party_create(struct map_session_data *sd,char *name,int item,int item2) { + struct party_member leader; nullpo_retr(0, sd); - if(sd->status.party_id==0) - intif_create_party(sd,name,item,item2); - else + if(sd->status.party_id) { clif_party_created(sd,2); + return 0; + } + + party_fill_member(&leader, sd); + leader.leader = 1; + + intif_create_party(&leader,name,item,item2); return 0; } @@ -176,21 +199,27 @@ static void party_check_state(struct party_data *p) memset(&p->state, 0, sizeof(p->state)); for (i = 0; i < MAX_PARTY; i ++) { - if (!p->data[i].sd) continue; - if ((p->data[i].sd->class_&MAPID_UPPERMASK) == MAPID_MONK) + if (!p->party.member[i].online) continue; //Those not online shouldn't aport to skill usage and all that. + switch (p->party.member[i].class_) { + case JOB_MONK: + case JOB_BABY_MONK: + case JOB_CHAMPION: p->state.monk = 1; - else - if ((p->data[i].sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR) + break; + case JOB_STAR_GLADIATOR: p->state.sg = 1; - else - if ((p->data[i].sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) + break; + case JOB_SUPER_NOVICE: + case JOB_SUPER_BABY: p->state.snovice = 1; - else - if ((p->data[i].sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON) + break; + case JOB_TAEKWON: p->state.tk = 1; + break; + } } - //TODO: Family state check. } + int party_recv_info(struct party *sp) { struct map_session_data *sd; @@ -271,11 +300,12 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd) int 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; nullpo_retr(0, sd); if(flag==1){ - intif_party_addmember( sd->party_invite, sd); + party_fill_member(&member, sd); + intif_party_addmember(sd->party_invite, &member); return 0; } sd->party_invite=0; @@ -308,7 +338,6 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) return 0; } - sd2=map_id2sd(sd->party_invite_account); if(!flag) { sd->state.party_sent=0; sd->status.party_id=party_id; @@ -316,6 +345,8 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) clif_party_join_info(&p->party,sd); clif_charnameupdate(sd); //Update char name's display [Skotlex] } + + sd2=map_id2sd(sd->party_invite_account); if (sd2) clif_party_inviteack(sd2,sd->status.name,flag?2:0); return 0; @@ -387,6 +418,8 @@ int party_member_leaved(int party_id,int account_id,int char_id) clif_party_leaved(p,sd,account_id,p->party.member[i].name,0x00); memset(&p->party.member[i], 0, sizeof(p->party.member[0])); memset(&p->data[i], 0, sizeof(p->data[0])); + p->party.count--; + party_check_state(p); break; } } @@ -394,7 +427,6 @@ int party_member_leaved(int party_id,int account_id,int char_id) sd->status.party_id=0; sd->state.party_sent=0; clif_charnameupdate(sd); //Update name display [Skotlex] - party_check_state(p); } return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index cfc4ccd4b..1aac9f22c 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -3546,7 +3546,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in } // 100% success rate at lv4 & 5, but lasts longer at lv5 i = skilllv <4?(60+skilllv*10):100; - i = sc_start(bl,type,100,skilllv,skill_get_time(skillid,skilllv)); + i = sc_start(bl,type,i,skilllv,skill_get_time(skillid,skilllv)); if(!i) { if (sd) clif_skill_fail(sd,skillid,0,0); if (skill_break_equip(bl, EQP_WEAPON, 10000, BCT_PARTY) && -- cgit v1.2.3-70-g09d2