summaryrefslogtreecommitdiff
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
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
-rw-r--r--Changelog-Trunk.txt9
-rw-r--r--src/char_sql/int_party.c1
-rw-r--r--src/common/mmo.h2
-rw-r--r--src/map/atcommand.c52
-rw-r--r--src/map/clif.c139
-rw-r--r--src/map/clif.h10
-rw-r--r--src/map/map.c2
-rw-r--r--src/map/map.h22
-rw-r--r--src/map/mob.c4
-rw-r--r--src/map/party.c460
-rw-r--r--src/map/party.h10
-rw-r--r--src/map/pc.c14
-rw-r--r--src/map/script.c26
13 files changed, 384 insertions, 367 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index ddc7a80cc..ede7c247f 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,15 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/06/09
+ * 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. Family information is still
+ missing, and handling of the state should probably be done by the
+ char-server, too... [Skotlex]
+ * party Hp updates are no longer done each time the Hp is modified, but
+ together with the party xy timer. It means HP-bars will be a bit delayed
+ before being updated, but packet consumption should be much less during
+ heated battles. [Skotlex]
* Fixed MoM's typo [Vicious]
* Fixed map_readafm missing strcpy(afm_name, m->name). [Skotlex]
* [Improved]:
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index f54ddfe20..fa0d3efb4 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -519,7 +519,6 @@ int mapif_parse_CreateParty(int fd, int account_id, int char_id, char *name, cha
memcpy(p->name,name,NAME_LENGTH);
p->exp=0;
p->item=(item?1:0)|(item2?2:0);
- p->itemc = 0;
p->member[0].account_id=account_id;
p->member[0].char_id =char_id;
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 205c943c5..88785fe78 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -244,7 +244,6 @@ struct party_member {
int account_id;
int char_id;
char name[NAME_LENGTH];
- struct map_session_data *sd;
unsigned short map;
unsigned short lv;
unsigned leader : 1,
@@ -256,7 +255,6 @@ struct party {
char name[NAME_LENGTH];
unsigned exp : 1,
item : 2; //&1: Party-Share (round-robin), &2: pickup style: shared.
- short itemc; //For item sharing through round-robin, holds last item receiver.
struct party_member member[MAX_PARTY];
};
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 0b9a0808f..6cef53b59 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1600,7 +1600,7 @@ int atcommand_who(
char match_text[100];
char player_name[NAME_LENGTH];
struct guild *g;
- struct party *p;
+ struct party_data *p;
nullpo_retr(-1, sd);
@@ -1639,7 +1639,7 @@ int atcommand_who(
//Players Party if exists
if (p != NULL) {
//sprintf(temp0," | Party: '%s'", p->name);
- sprintf(temp0, msg_txt(335), p->name);
+ sprintf(temp0, msg_txt(335), p->party.name);
strcat(atcmd_output,temp0);
}
//Players Guild if exists
@@ -1801,7 +1801,7 @@ int atcommand_whomap(
int map_id = 0;
char map_name[MAP_NAME_LENGTH];
struct guild *g;
- struct party *p;
+ struct party_data *p;
nullpo_retr(-1, sd);
@@ -1838,7 +1838,7 @@ int atcommand_whomap(
if (p == NULL)
sprintf(temp0, "None");
else
- sprintf(temp0, "%s", p->name);
+ sprintf(temp0, "%s", p->party.name);
if (pl_GM_level > 0)
sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
else
@@ -1878,7 +1878,7 @@ int atcommand_whogm(
char match_text[100];
char player_name[NAME_LENGTH];
struct guild *g;
- struct party *p;
+ struct party_data *p;
nullpo_retr(-1, sd);
@@ -1918,7 +1918,7 @@ int atcommand_whogm(
if (p == NULL)
sprintf(temp0, "None");
else
- sprintf(temp0, "%s", p->name);
+ sprintf(temp0, "%s", p->party.name);
sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
clif_displaymessage(fd, atcmd_output);
count++;
@@ -5380,7 +5380,7 @@ int atcommand_partyrecall(
int i;
struct map_session_data *pl_sd, **pl_allsd;
char party_name[NAME_LENGTH];
- struct party *p;
+ struct party_data *p;
int count, users;
nullpo_retr(-1, sd);
@@ -5404,7 +5404,7 @@ int atcommand_partyrecall(
pl_allsd = map_getallusers(&users);
for (i = 0; i < users; i++) {
if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
- pl_sd->status.party_id == p->party_id) {
+ pl_sd->status.party_id == p->party.party_id) {
if (pc_isGM(pl_sd) > pc_isGM(sd))
continue; //Skip GMs greater than you.
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
@@ -5413,7 +5413,7 @@ int atcommand_partyrecall(
pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
}
}
- sprintf(atcmd_output, msg_table[95], p->name); // All online characters of the %s party are near you.
+ sprintf(atcmd_output, msg_table[95], p->party.name); // All online characters of the %s party are near you.
clif_displaymessage(fd, atcmd_output);
if (count) {
sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
@@ -5937,7 +5937,7 @@ int atcommand_partyspy(
const char* command, const char* message)
{
char party_name[NAME_LENGTH];
- struct party *p;
+ struct party_data *p;
nullpo_retr(-1, sd);
memset(party_name, '\0', sizeof(party_name));
@@ -5956,13 +5956,13 @@ int atcommand_partyspy(
if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
(p = party_search(atoi(message))) != NULL) {
- if (sd->partyspy == p->party_id) {
+ if (sd->partyspy == p->party.party_id) {
sd->partyspy = 0;
- sprintf(atcmd_output, msg_table[105], p->name); // No longer spying on the %s party.
+ sprintf(atcmd_output, msg_table[105], p->party.name); // No longer spying on the %s party.
clif_displaymessage(fd, atcmd_output);
} else {
- sd->partyspy = p->party_id;
- sprintf(atcmd_output, msg_table[106], p->name); // Spying on the %s party.
+ sd->partyspy = p->party.party_id;
+ sprintf(atcmd_output, msg_table[106], p->party.name); // Spying on the %s party.
clif_displaymessage(fd, atcmd_output);
}
} else {
@@ -7656,7 +7656,7 @@ atcommand_changeleader(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
- struct party *p;
+ struct party_data *p;
struct map_session_data *pl_sd;
int mi, pl_mi;
nullpo_retr(-1, sd);
@@ -7667,12 +7667,12 @@ atcommand_changeleader(
return -1;
}
- for (mi = 0; mi < MAX_PARTY && p->member[mi].sd != sd; mi++);
+ for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
if (mi == MAX_PARTY)
return -1; //Shouldn't happen
- if (!p->member[mi].leader)
+ if (!p->party.member[mi].leader)
{
clif_displaymessage(fd, "You need to be the party's leader to use this command.");
return -1;
@@ -7689,20 +7689,20 @@ atcommand_changeleader(
return -1;
}
- for (pl_mi = 0; pl_mi < MAX_PARTY && p->member[pl_mi].sd != pl_sd; pl_mi++);
+ for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
if (pl_mi == MAX_PARTY)
return -1; //Shouldn't happen
//Change leadership.
- p->member[mi].leader = 0;
- if (p->member[mi].sd->fd)
- clif_displaymessage(p->member[mi].sd->fd, "Leadership transferred.");
- p->member[pl_mi].leader = 1;
- if (p->member[pl_mi].sd->fd)
- clif_displaymessage(p->member[pl_mi].sd->fd, "You've become the party leader.");
-
- intif_party_leaderchange(p->party_id,p->member[pl_mi].account_id,p->member[pl_mi].char_id);
+ p->party.member[mi].leader = 0;
+ if (p->data[mi].sd->fd)
+ clif_displaymessage(p->data[mi].sd->fd, "Leadership transferred.");
+ p->party.member[pl_mi].leader = 1;
+ if (p->data[pl_mi].sd->fd)
+ clif_displaymessage(p->data[pl_mi].sd->fd, "You've become the party leader.");
+
+ intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
//Update info.
clif_party_main_info(p,-1);
clif_party_info(p,-1);
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;
diff --git a/src/map/clif.h b/src/map/clif.h
index da64c733a..a50f8ec18 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -260,14 +260,14 @@ int clif_movetoattack(struct map_session_data *sd,struct block_list *bl);
// party
int clif_party_created(struct map_session_data *sd,int flag);
-int clif_party_main_info(struct party *p, int fd);
+int clif_party_main_info(struct party_data *p, int fd);
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);
int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd);
int clif_party_inviteack(struct map_session_data *sd,char *nick,int flag);
-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_message(struct party *p,int account_id,char *mes,int len);
+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,char *name,int flag);
+int clif_party_message(struct party_data *p,int account_id,char *mes,int len);
int clif_party_move(struct party *p,struct map_session_data *sd,int online);
int clif_party_xy(struct map_session_data *sd);
int clif_party_xy_single(int fd, struct map_session_data *sd);
diff --git a/src/map/map.c b/src/map/map.c
index ef137b965..7766e194c 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2801,9 +2801,11 @@ static int map_loadafm (struct map_data *m, char *fn)
int afm_size[2];
char *str;
+ //Gotta skip the first two lines which are just a header of sorts.
str = fgets(afm_line, sizeof(afm_line)-1, afm_file);
str = fgets(afm_line, sizeof(afm_line)-1, afm_file);
str = fgets(afm_line, sizeof(afm_line)-1, afm_file);
+ if (!str) return 0;
sscanf(str , "%d%d", &afm_size[0], &afm_size[1]);
xs = m->xs = afm_size[0];
diff --git a/src/map/map.h b/src/map/map.h
index c0ed9cf16..9f7fd1034 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -417,6 +417,27 @@ struct view_data {
char sex;
unsigned dead_sit : 2;
};
+
+struct party_member_data {
+ struct map_session_data *sd;
+ unsigned int hp; //For HP,x,y refreshing.
+ unsigned short x, y;
+};
+
+struct party_data {
+ struct party party;
+ struct party_member_data data[MAX_PARTY];
+ unsigned char count; //Online count of members.
+ unsigned char itemc; //For item distribution.
+ struct {
+ unsigned family : 1; //Is this party a family?
+ unsigned monk : 1; //There's at least one monk in party?
+ unsigned sg : 1; //There's at least one Star Gladiator in party?
+ unsigned snovice :1; //There's a Super Novice
+ unsigned tk : 1; //There's a taekwon
+ } state;
+};
+
struct npc_data;
struct pet_db;
struct item_data;
@@ -668,7 +689,6 @@ struct map_session_data {
} deal;
int party_invite,party_invite_account;
- short party_x,party_y; // should be short [zzo]
int guild_invite,guild_invite_account;
int guild_emblem_id,guild_alliance,guild_alliance_account;
diff --git a/src/map/mob.c b/src/map/mob.c
index 8d9b69626..65331f343 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1694,7 +1694,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
*mvp_sd = NULL, *second_sd = NULL,*third_sd = NULL;
struct {
- struct party *p;
+ struct party_data *p;
int id,zeny;
unsigned int base_exp,job_exp;
} pt[DAMAGELOG_SIZE];
@@ -1870,7 +1870,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if(j==pnum){ //Possibly add party.
pt[pnum].p = party_search(temp);
- if(pt[pnum].p && pt[pnum].p->exp)
+ if(pt[pnum].p && pt[pnum].p->party.exp)
{
pt[pnum].id=temp;
pt[pnum].base_exp=base_exp;
diff --git a/src/map/party.c b/src/map/party.c
index b7c00db4d..65e8e6f9f 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -25,7 +25,7 @@
#define PARTY_SEND_XY_INVERVAL 1000 // 座標やHP送信の間隔
static struct dbt* party_db;
-static struct party* party_cache = NULL; //party in cache for skipping consecutive lookups. [Skotlex]
+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);
/*==========================================
@@ -45,9 +45,10 @@ void do_init_party(void)
}
// 検索
-struct party *party_search(int party_id)
+struct party_data *party_search(int party_id)
{
- if (party_cache && party_cache->party_id == party_id)
+ if(!party_id) return NULL;
+ if (party_cache && party_cache->party.party_id == party_id)
return party_cache;
party_cache = idb_get(party_db,party_id);
@@ -55,22 +56,22 @@ struct party *party_search(int party_id)
}
int party_searchname_sub(DBKey key,void *data,va_list ap)
{
- struct party *p=(struct party *)data,**dst;
+ struct party_data *p=(struct party_data *)data,**dst;
char *str;
str=va_arg(ap,char *);
- dst=va_arg(ap,struct party **);
- if(strncmpi(p->name,str,NAME_LENGTH)==0)
+ dst=va_arg(ap,struct party_data **);
+ if(strncmpi(p->party.name,str,NAME_LENGTH)==0)
*dst=p;
return 0;
}
-// パーティ名検索
-struct party* party_searchname(char *str)
+
+struct party_data* party_searchname(char *str)
{
- struct party *p=NULL;
+ struct party_data *p=NULL;
party_db->foreach(party_db,party_searchname_sub,str,&p);
return p;
}
-// 作成要求
+
int party_create(struct map_session_data *sd,char *name,int item,int item2)
{
nullpo_retr(0, sd);
@@ -82,42 +83,40 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2)
return 0;
}
-// 作成可否
+
int party_created(int account_id,int char_id,int fail,int party_id,char *name)
{
struct map_session_data *sd;
+ struct party_data *p;
sd=map_id2sd(account_id);
nullpo_retr(0, sd);
if (sd->status.char_id != char_id)
return 0; //unlikely failure...
- if(fail==0){
- struct party *p;
- sd->status.party_id=party_id;
- if(idb_get(party_db,party_id)!=NULL){
- ShowFatalError("party: id already exists!\n");
- exit(1);
- }
- p=(struct party *)aCalloc(1,sizeof(struct party));
- p->party_id=party_id;
- memcpy(p->name, name, NAME_LENGTH);
- idb_put(party_db,party_id,p);
- clif_party_created(sd,0); //Success message
- clif_charnameupdate(sd); //Update other people's display. [Skotlex]
- }else{
+ if(fail){
clif_party_created(sd,1);
+ return 0;
}
- return 0;
+ sd->status.party_id=party_id;
+ if(idb_get(party_db,party_id)!=NULL){
+ ShowFatalError("party: id already exists!\n");
+ exit(1);
+ }
+ p=(struct party_data *)aCalloc(1,sizeof(struct party_data));
+ p->party.party_id=party_id;
+ memcpy(p->party.name, name, NAME_LENGTH);
+ idb_put(party_db,party_id,p);
+ clif_party_created(sd,0); //Success message
+ clif_charnameupdate(sd); //Update other people's display. [Skotlex]
+ return 1;
}
-// 情報要求
int party_request_info(int party_id)
{
return intif_request_partyinfo(party_id);
}
-// 所属キャラの確認
int party_check_member(struct party *p)
{
int i, users;
@@ -151,7 +150,6 @@ int party_check_member(struct party *p)
return 0;
}
-// 情報所得失敗(そのIDのキャラを全部未所属にする)
int party_recv_noinfo(int party_id)
{
int i, users;
@@ -167,57 +165,75 @@ int party_recv_noinfo(int party_id)
}
static void* create_party(DBKey key, va_list args) {
- struct party *p;
- p=(struct party *)aCalloc(1,sizeof(struct party));
+ struct party_data *p;
+ p=(struct party_data *)aCalloc(1,sizeof(struct party_data));
return p;
}
-// 情報所得
+
+static void party_check_state(struct party_data *p)
+{
+ int i;
+ 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)
+ p->state.monk = 1;
+ else
+ if ((p->data[i].sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR)
+ p->state.sg = 1;
+ else
+ if ((p->data[i].sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE)
+ p->state.snovice = 1;
+ else
+ if ((p->data[i].sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON)
+ p->state.tk = 1;
+ }
+ //TODO: Family state check.
+}
int party_recv_info(struct party *sp)
{
struct map_session_data *sd;
- struct party *p;
+ struct party_data *p;
int i;
nullpo_retr(0, sp);
p= idb_ensure(party_db, sp->party_id, create_party);
- if (!p->party_id) //party just received.
+ if (!p->party.party_id) //party just received.
party_check_member(sp);
- memcpy(p,sp,sizeof(struct party));
-
- for(i=0;i<MAX_PARTY;i++){ // sdの設定
- if (!p->member[i].account_id) {
- p->member[i].sd=NULL;
+ memcpy(&p->party,sp,sizeof(struct party));
+ p->count = 0;
+ memset(&p->state, 0, sizeof(p->state));
+ memset(&p->data, 0, sizeof(p->data));
+ for(i=0;i<MAX_PARTY;i++){
+ if (!p->party.member[i].account_id)
continue;
- }
- sd = map_id2sd(p->member[i].account_id);
- p->member[i].sd = (sd!=NULL && sd->status.party_id==p->party_id && sd->status.char_id == p->member[i].char_id && !sd->state.waitingdisconnect)?sd:NULL;
- }
-
-
- for(i=0;i<MAX_PARTY;i++){ // 設定情報の送信
- sd = p->member[i].sd;
- if(!sd)
+ sd = map_id2sd(p->party.member[i].account_id);
+ if (sd && sd->status.party_id==p->party.party_id
+ && sd->status.char_id == p->party.member[i].char_id
+ && !sd->state.waitingdisconnect)
+ p->data[i].sd = sd;
+ p->count++;
+ }
+ party_check_state(p);
+ for(i=0;i<MAX_PARTY;i++){
+ sd = p->data[i].sd;
+ if(!sd || sd->state.party_sent)
continue;
- // Refresh hp/xy state [LuzZza]
- clif_party_hp(sd);
- clif_party_xy(sd);
- if(sd->state.party_sent==0){
- clif_party_main_info(p,-1);
- clif_party_option(p,sd,0x100);
- clif_party_info(p,-1);
- sd->state.party_sent=1;
- }
+ clif_party_main_info(p,-1);
+ clif_party_option(p,sd,0x100);
+ clif_party_info(p,-1);
+ sd->state.party_sent=1;
}
return 0;
}
-// パーティへの勧誘
int party_invite(struct map_session_data *sd,int account_id)
{
struct map_session_data *tsd= map_id2sd(account_id);
- struct party *p=party_search(sd->status.party_id);
+ struct party_data *p=party_search(sd->status.party_id);
int i,flag=0;
nullpo_retr(0, sd);
@@ -225,19 +241,20 @@ int party_invite(struct map_session_data *sd,int account_id)
if(tsd==NULL || p==NULL)
return 0;
if(!battle_config.invite_request_check) {
- if (tsd->guild_invite>0 || tsd->trade_partner) { // 相手が取引中かどうか
+ if (tsd->guild_invite>0 || tsd->trade_partner) {
clif_party_inviteack(sd,tsd->status.name,0);
return 0;
}
}
- if( tsd->status.party_id>0 || tsd->party_invite>0 ){ // 相手の所属確認
+ if( tsd->status.party_id>0 || tsd->party_invite>0 ){
clif_party_inviteack(sd,tsd->status.name,0);
return 0;
}
for(i=0;i<MAX_PARTY;i++){
- if(p->member[i].account_id == 0) //Room for a new member.
+ if(p->party.member[i].account_id == 0) //Room for a new member.
flag = 1;
- if(p->member[i].account_id==account_id && p->member[i].char_id==tsd->status.char_id){
+ if(p->party.member[i].account_id==account_id &&
+ p->party.member[i].char_id==tsd->status.char_id){
clif_party_inviteack(sd,tsd->status.name,0);
return 0;
}
@@ -253,37 +270,34 @@ int party_invite(struct map_session_data *sd,int account_id)
clif_party_invite(sd,tsd);
return 1;
}
-// パーティ勧誘への返答
+
int party_reply_invite(struct map_session_data *sd,int account_id,int flag)
{
struct map_session_data *tsd= map_id2sd(account_id);
nullpo_retr(0, sd);
- if(flag==1){ // 承諾
- //inter鯖へ追加要求
+ if(flag==1){
intif_party_addmember( sd->party_invite, sd);
return 0;
}
- else { // 拒否
- sd->party_invite=0;
- sd->party_invite_account=0;
- if(tsd==NULL)
- return 0;
- clif_party_inviteack(tsd,sd->status.name,1);
- }
- 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;
}
-// パーティが追加された
+
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 *p = party_search(party_id);
+ struct party_data *p = party_search(party_id);
if(sd == NULL || sd->status.char_id != char_id){
if (flag == 0) {
if(battle_config.error_log)
ShowError("party: member added error %d is not online\n",account_id);
- intif_party_leave(party_id,account_id,char_id); // キャラ側i登録eきhかaたたぁ脱憎要求も出す
+ intif_party_leave(party_id,account_id,char_id);
}
return 0;
}
@@ -302,19 +316,17 @@ int party_member_added(int party_id,int account_id,int char_id, int flag)
sd->state.party_sent=0;
sd->status.party_id=party_id;
party_check_conflict(sd);
- clif_party_join_info(p,sd);
+ clif_party_join_info(&p->party,sd);
clif_charnameupdate(sd); //Update char name's display [Skotlex]
- clif_party_hp(sd);
- clif_party_xy(sd);
}
if (sd2)
clif_party_inviteack(sd2,sd->status.name,flag?2:0);
return 0;
}
-// パーティ除名要求
+
int party_removemember(struct map_session_data *sd,int account_id,char *name)
{
- struct party *p;
+ struct party_data *p;
int i;
nullpo_retr(0, sd);
@@ -322,9 +334,10 @@ int party_removemember(struct map_session_data *sd,int account_id,char *name)
if( (p = party_search(sd->status.party_id)) == NULL )
return 0;
- for(i=0;i<MAX_PARTY;i++){ // リーダーかどうかチェック
- if(p->member[i].account_id==sd->status.account_id && p->member[i].char_id==sd->status.char_id) {
- if(p->member[i].leader)
+ for(i=0;i<MAX_PARTY;i++){
+ if(p->party.member[i].account_id==sd->status.account_id &&
+ p->party.member[i].char_id==sd->status.char_id) {
+ if(p->party.member[i].leader)
break;
return 0;
}
@@ -332,20 +345,20 @@ int party_removemember(struct map_session_data *sd,int account_id,char *name)
if (i >= MAX_PARTY) //Request from someone not in party? o.O
return 0;
- for(i=0;i<MAX_PARTY;i++){ // 所属しているか調べる
- if(p->member[i].account_id==account_id && strncmp(p->member[i].name,name,NAME_LENGTH)==0)
+ for(i=0;i<MAX_PARTY;i++){
+ if(p->party.member[i].account_id==account_id &&
+ strncmp(p->party.member[i].name,name,NAME_LENGTH)==0)
{
- intif_party_leave(p->party_id,account_id,p->member[i].char_id);
+ intif_party_leave(p->party.party_id,account_id,p->party.member[i].char_id);
return 1;
}
}
return 0;
}
-// パーティ脱退要求
int party_leave(struct map_session_data *sd)
{
- struct party *p;
+ struct party_data *p;
int i;
nullpo_retr(0, sd);
@@ -353,61 +366,64 @@ int party_leave(struct map_session_data *sd)
if( (p = party_search(sd->status.party_id)) == NULL )
return 0;
- for(i=0;i<MAX_PARTY;i++){ // 所属しているか
- if(p->member[i].account_id==sd->status.account_id && p->member[i].char_id==sd->status.char_id){
- intif_party_leave(p->party_id,sd->status.account_id,sd->status.char_id);
+ for(i=0;i<MAX_PARTY;i++){
+ if(p->party.member[i].account_id==sd->status.account_id &&
+ p->party.member[i].char_id==sd->status.char_id){
+ intif_party_leave(p->party.party_id,sd->status.account_id,sd->status.char_id);
return 0;
}
}
return 0;
}
-// パーティメンバが脱退した
+
int party_member_leaved(int party_id,int account_id,int char_id)
{
struct map_session_data *sd=map_id2sd(account_id);
- struct party *p=party_search(party_id);
+ struct party_data *p=party_search(party_id);
+ int i;
if (sd && sd->status.char_id != char_id) //Wrong target
sd = NULL;
if(p!=NULL){
- int i;
for(i=0;i<MAX_PARTY;i++)
- if(p->member[i].account_id==account_id &&
- p->member[i].char_id==char_id){
- clif_party_leaved(p,sd,account_id,p->member[i].name,0x00);
- p->member[i].account_id=0;
- p->member[i].char_id=0;
- p->member[i].sd=NULL;
+ if(p->party.member[i].account_id==account_id &&
+ p->party.member[i].char_id==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->count--;
+ break;
}
}
if(sd!=NULL && sd->status.party_id==party_id){
sd->status.party_id=0;
sd->state.party_sent=0;
clif_charnameupdate(sd); //Update name display [Skotlex]
+ party_check_state(p);
}
return 0;
}
-// パーティ解散通知
+
int party_broken(int party_id)
{
- struct party *p;
+ struct party_data *p;
int i;
if( (p=party_search(party_id))==NULL )
return 0;
for(i=0;i<MAX_PARTY;i++){
- if(p->member[i].sd!=NULL){
- clif_party_leaved(p,p->member[i].sd,
- p->member[i].account_id,p->member[i].name,0x10);
- p->member[i].sd->status.party_id=0;
- p->member[i].sd->state.party_sent=0;
+ if(p->data[i].sd!=NULL){
+ clif_party_leaved(p,p->data[i].sd,
+ p->party.member[i].account_id,p->party.member[i].name,0x10);
+ p->data[i].sd->status.party_id=0;
+ p->data[i].sd->state.party_sent=0;
}
}
- if (party_cache && party_cache->party_id == party_id)
+ if (party_cache && party_cache->party.party_id == party_id)
party_cache = NULL;
idb_remove(party_db,party_id);
return 0;
}
-// パーティの設定変更要求
+
int party_changeoption(struct map_session_data *sd,int exp,int flag)
{
nullpo_retr(0, sd);
@@ -417,54 +433,42 @@ int party_changeoption(struct map_session_data *sd,int exp,int flag)
intif_party_changeoption(sd->status.party_id,sd->status.account_id,exp,flag);
return 0;
}
-// パーティの設定変更通知
+
int party_optionchanged(int party_id,int account_id,int exp,int item,int flag)
{
- struct party *p;
+ struct party_data *p;
struct map_session_data *sd=map_id2sd(account_id);
if( (p=party_search(party_id))==NULL)
return 0;
- if(!(flag&0x01)) p->exp=exp;
- if(!(flag&0x10)) p->item=item;
+ if(!(flag&0x01)) p->party.exp=exp;
+ if(!(flag&0x10)) p->party.item=item;
clif_party_option(p,sd,flag);
return 0;
}
-// パーティメンバの移動通知
int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv)
{
- struct party *p;
+ struct party_data *p;
int i;
if( (p=party_search(party_id))==NULL)
return 0;
for(i=0;i<MAX_PARTY;i++){
struct map_session_data *sd;
- struct party_member *m=&p->member[i];
- /* This can never happen...
- if( m == NULL ){
- ShowError("party_recv_movemap nullpo?\n");
- return 0;
- }
- */
+ struct party_member *m=&p->party.member[i];
if(m->account_id==account_id && m->char_id==char_id){
m->map = map;
m->online=online;
m->lv=lv;
//Check if they still exist on this map server
sd = map_id2sd(m->account_id);
- p->member[i].sd=(sd!=NULL && sd->status.party_id==p->party_id && sd->status.char_id == m->char_id && !sd->state.waitingdisconnect)?sd:NULL;
- //if so, clear their coordinates as they just changed maps.
- if (p->member[i].sd) {
- sd->party_x=-1;
- sd->party_y=-1;
- }
+ p->data[i].sd = (sd!=NULL && sd->status.party_id==p->party.party_id && sd->status.char_id == m->char_id && !sd->state.waitingdisconnect)?sd:NULL;
break;
}
}
if(i==MAX_PARTY){
if(battle_config.error_log)
- ShowError("party: not found member %d on %d[%s]",account_id,party_id,p->name);
+ ShowError("party: not found member %d/%d on %d[%s]",account_id,char_id,party_id,p->party.name);
return 0;
}
@@ -472,11 +476,10 @@ int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short m
return 0;
}
-// パーティメンバの移動
int party_send_movemap(struct map_session_data *sd)
{
int i;
- struct party *p;
+ struct party_data *p;
nullpo_retr(0, sd);
@@ -484,29 +487,26 @@ int party_send_movemap(struct map_session_data *sd)
return 0;
intif_party_changemap(sd,1);
-
p=party_search(sd->status.party_id);
if (p && sd->fd) {
//Send dots of other party members to this char. [Skotlex]
for(i=0; i < MAX_PARTY; i++) {
- if (!p->member[i].sd || p->member[i].sd == sd ||
- p->member[i].sd->bl.m != sd->bl.m)
+ if (!p->data[i].sd || p->data[i].sd == sd ||
+ p->data[i].sd->bl.m != sd->bl.m)
continue;
- clif_party_xy_single(sd->fd, p->member[i].sd);
+ clif_party_xy_single(sd->fd, p->data[i].sd);
}
}
- if( sd->state.party_sent ) // もうパーティデータは送信済み
+ if( sd->state.party_sent )
return 0;
- // 競合確認
party_check_conflict(sd);
- // あるならパーティ情報送信
if(p){
- party_check_member(p); // 所属を確認する
- if(sd->status.party_id==p->party_id){
+ party_check_member(&p->party);
+ if(sd->status.party_id==p->party.party_id){
clif_party_main_info(p,sd->fd);
clif_party_option(p,sd,0x100);
clif_party_info(p,sd->fd);
@@ -516,52 +516,50 @@ int party_send_movemap(struct map_session_data *sd)
return 0;
}
-// パーティメンバのログアウト
+
int party_send_logout(struct map_session_data *sd)
{
- struct party *p;
-
- nullpo_retr(0, sd);
+ struct party_data *p;
+ int i;
- if( sd->status.party_id>0 )
- intif_party_changemap(sd,0);
+ if(!sd->status.party_id)
+ return 0;
- // sdが無効になるのでパーティ情報から削除
- if( (p=party_search(sd->status.party_id))!=NULL ){
- int i;
- for(i=0;i<MAX_PARTY;i++)
- if(p->member[i].sd==sd)
- p->member[i].sd=NULL;
- }
+ intif_party_changemap(sd,0);
+ p=party_search(sd->status.party_id);
+ if(!p) return 0;
+
+ for(i=0;i<MAX_PARTY && p->data[i].sd != sd;i++);
+ if (i < MAX_PARTY)
+ memset(&p->data[i], 0, sizeof(p->data[0]));
- return 0;
+ return 1;
}
-// パーティメッセージ送信
+
int party_send_message(struct map_session_data *sd,char *mes,int len)
{
if(sd->status.party_id==0)
return 0;
intif_party_message(sd->status.party_id,sd->status.account_id,mes,len);
- party_recv_message(sd->status.party_id,sd->status.account_id,mes,len);
+ party_recv_message(sd->status.party_id,sd->status.account_id,mes,len);
//Chat Logging support Type 'P'
if(log_config.chat&1 //we log everything then
- || ( log_config.chat&4 //if Party bit is on
+ || (log_config.chat&4 //if Party bit is on
&& ( !agit_flag || !(log_config.chat&16) ))) //if WOE ONLY flag is off or AGIT is OFF
log_chat("P", sd->status.party_id, sd->status.char_id, sd->status.account_id, (char*)mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
return 0;
}
-// パーティメッセージ受信
int party_recv_message(int party_id,int account_id,char *mes,int len)
{
- struct party *p;
+ struct party_data *p;
if( (p=party_search(party_id))==NULL)
return 0;
clif_party_message(p,account_id,mes,len);
return 0;
}
-// パーティ競合確認
+
int party_check_conflict(struct map_session_data *sd)
{
nullpo_retr(0, sd);
@@ -572,14 +570,29 @@ int party_check_conflict(struct map_session_data *sd)
int party_skill_check(struct map_session_data *sd, int party_id, int skillid, int skilllv)
{
- struct party *p;
+ struct party_data *p;
struct map_session_data *p_sd;
int i;
if(!party_id || (p=party_search(party_id))==NULL)
return 0;
+ switch(skillid) {
+ case TK_COUNTER: //Increase Triple Attack rate of Monks.
+ if (!p->state.monk) return 0;
+ break;
+ case MO_TRIPLEATTACK: //Increase Counter rate of Star Gladiators
+ if (!p->state.sg) return 0;
+ break;
+ case AM_TWILIGHT2: //Twilight Pharmacy, requires Super Novice
+ return p->state.snovice;
+ case AM_TWILIGHT3: //Twilight Pharmacy, Requires Taekwon
+ return p->state.tk;
+ default:
+ return 0; //Unknown case?
+ }
+
for(i=0;i<MAX_PARTY;i++){
- if ((p_sd = p->member[i].sd) == NULL)
+ if ((p_sd = p->data[i].sd) == NULL)
continue;
switch(skillid) {
case TK_COUNTER: //Increase Triple Attack rate of Monks.
@@ -598,68 +611,60 @@ int party_skill_check(struct map_session_data *sd, int party_id, int skillid, in
sc_start4(&p_sd->bl,SC_SKILLRATE_UP,100,TK_COUNTER,rate,0,0,skill_get_time(SG_FRIEND, 1));
}
break;
- case AM_TWILIGHT2: //Twilight Pharmacy, requires Super Novice
- if ((p_sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE
- && sd->bl.m == p_sd->bl.m)
- return 1;
- break;
- case AM_TWILIGHT3: //Twilight Pharmacy, Requires Taekwon
- if ((p_sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON
- && sd->bl.m == p_sd->bl.m)
- return 1;
- break;
}
}
return 0;
}
-// 位置やHP通知用
int party_send_xy_timer_sub(DBKey key,void *data,va_list ap)
{
- struct party *p=(struct party *)data;
+ struct party_data *p=(struct party_data *)data;
+ struct map_session_data *sd;
int i;
nullpo_retr(0, p);
for(i=0;i<MAX_PARTY;i++){
- struct map_session_data *sd;
- if((sd=p->member[i].sd)!=NULL){
- // 座標通知
- if(sd->party_x!=sd->bl.x || sd->party_y!=sd->bl.y){
- clif_party_xy(sd);
- sd->party_x=sd->bl.x;
- sd->party_y=sd->bl.y;
- }
+ if(!p->data[i].sd) continue;
+ sd = p->data[i].sd;
+ if (p->data[i].x != sd->bl.x || p->data[i].y != sd->bl.y)
+ {
+ clif_party_xy(sd);
+ p->data[i].x = sd->bl.x;
+ p->data[i].y = sd->bl.y;
+ }
+ if (p->data[i].hp != sd->battle_status.hp)
+ {
+ clif_party_hp(sd);
+ p->data[i].hp = sd->battle_status.hp;
}
}
return 0;
}
-// 位置やHP通知
+
int party_send_xy_timer(int tid,unsigned int tick,int id,int data)
{
party_db->foreach(party_db,party_send_xy_timer_sub,tick);
return 0;
}
-// 位置通知クリア
-int party_send_xy_clear(struct party *p)
+int party_send_xy_clear(struct party_data *p)
{
int i;
nullpo_retr(0, p);
for(i=0;i<MAX_PARTY;i++){
- struct map_session_data *sd;
- if((sd=p->member[i].sd)!=NULL){
- sd->party_x=-1;
- sd->party_y=-1;
- }
+ if(!p->data[i].sd) continue;
+ p->data[i].hp = 0;
+ p->data[i].x = 0;
+ p->data[i].y = 0;
}
return 0;
}
// exp share and added zeny share [Valaris]
-int party_exp_share(struct party *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny)
+int party_exp_share(struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny)
{
struct map_session_data* sd[MAX_PARTY];
int i;
@@ -668,7 +673,7 @@ int party_exp_share(struct party *p,struct block_list *src,unsigned int base_exp
nullpo_retr(0, p);
for (i = c = 0; i < MAX_PARTY; i++)
- if ((sd[c] = p->member[i].sd)!=NULL && sd[c]->bl.m == src->m && !pc_isdead(sd[c])) {
+ if ((sd[c] = p->data[i].sd)!=NULL && sd[c]->bl.m == src->m && !pc_isdead(sd[c])) {
if (battle_config.idle_no_share && (sd[c]->chatID || sd[c]->vender_id || (sd[c]->idletime < (last_tick - battle_config.idle_no_share))))
continue;
c++;
@@ -701,11 +706,11 @@ int party_exp_share(struct party *p,struct block_list *src,unsigned int base_exp
return 0;
}
-int party_share_loot(struct party *p, TBL_PC *sd, struct item *item_data)
+int party_share_loot(struct party_data *p, TBL_PC *sd, struct item *item_data)
{
TBL_PC *target=NULL;
int i;
- if (p && p->item&2) {
+ if (p && p->party.item&2) {
//item distribution to party members.
if (battle_config.party_share_type) { //Round Robin
TBL_PC *psd;
@@ -714,7 +719,7 @@ int party_share_loot(struct party *p, TBL_PC *sd, struct item *item_data)
i++;
if (i >= MAX_PARTY)
i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc"
- if ((psd=p->member[i].sd)==NULL || sd->bl.m != psd->bl.m ||
+ if ((psd=p->data[i].sd)==NULL || sd->bl.m != psd->bl.m ||
pc_isdead(psd) || (battle_config.idle_no_share && (
psd->chatID || psd->vender_id || (psd->idletime < (last_tick - battle_config.idle_no_share)))
))
@@ -732,25 +737,23 @@ int party_share_loot(struct party *p, TBL_PC *sd, struct item *item_data)
int count=0;
//Collect pick candidates
for (i = 0; i < MAX_PARTY; i++) {
- if ((psd[count]=p->member[i].sd) && psd[count]->bl.m == sd->bl.m &&
+ if ((psd[count]=p->data[i].sd) && psd[count]->bl.m == sd->bl.m &&
!pc_isdead(psd[count]) && (!battle_config.idle_no_share || (
!psd[count]->chatID && !psd[count]->vender_id &&
(psd[count]->idletime >= (last_tick - battle_config.idle_no_share)))
))
count++;
}
- if (count > 0) { //Pick a random member.
- do {
- i = rand()%count;
- if (pc_additem(psd[i],item_data,item_data->amount))
- { //Discard this receiver.
- psd[i] = psd[count-1];
- count--;
- } else { //Successful pick.
- target = psd[i];
- break;
- }
- } while (count > 0);
+ while (count > 0) { //Pick a random member.
+ i = rand()%count;
+ if (pc_additem(psd[i],item_data,item_data->amount))
+ { //Discard this receiver.
+ psd[i] = psd[count-1];
+ count--;
+ } else { //Successful pick.
+ target = psd[i];
+ break;
+ }
}
}
}
@@ -773,9 +776,9 @@ int party_share_loot(struct party *p, TBL_PC *sd, struct item *item_data)
int party_send_dot_remove(struct map_session_data *sd)
{
-if (sd->status.party_id)
- clif_party_xy_remove(sd);
-return 0;
+ if (sd->status.party_id)
+ clif_party_xy_remove(sd);
+ return 0;
}
// To use for Taekwon's "Fighting Chant"
@@ -789,12 +792,9 @@ int party_sub_count(struct block_list *bl, va_list ap)
return 0;
}
-// 同じマップのパーティメンバー全体に処理をかける
-// type==0 同じマップ
-// !=0 画面内
int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_session_data *sd,int range,...)
{
- struct party *p;
+ struct party_data *p;
va_list ap;
int i;
int x0,y0,x1,y1;
@@ -815,25 +815,23 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess
va_start(ap,range);
for(i=0;i<MAX_PARTY;i++){
- struct party_member *m=&p->member[i];
- if(m->sd!=NULL){
- if(sd->bl.m!=m->sd->bl.m)
- continue;
- if(range &&
- (m->sd->bl.x<x0 || m->sd->bl.y<y0 ||
- m->sd->bl.x>x1 || m->sd->bl.y>y1 ) )
- continue;
- list[blockcount++]=&m->sd->bl;
- }
+ struct map_session_data *psd=p->data[i].sd;
+ if(!psd) continue;
+ if(psd->bl.m!=sd->bl.m || !psd->bl.prev)
+ continue;
+ if(range &&
+ (psd->bl.x<x0 || psd->bl.y<y0 ||
+ psd->bl.x>x1 || psd->bl.y>y1 ) )
+ continue;
+ list[blockcount++]=&sd->bl;
}
- map_freeblock_lock(); // メモリからの解放を禁止する
+ map_freeblock_lock();
for(i=0;i<blockcount;i++)
- if(list[i]->prev) // 有効かどうかチェック
- total += func(list[i],ap);
+ total += func(list[i],ap);
- map_freeblock_unlock(); // 解放を許可する
+ map_freeblock_unlock();
va_end(ap);
return total;
diff --git a/src/map/party.h b/src/map/party.h
index f813c5020..c305a6f51 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -14,8 +14,8 @@ struct block_list;
void do_init_party(void);
void do_final_party(void);
-struct party *party_search(int party_id);
-struct party* party_searchname(char *str);
+struct party_data *party_search(int party_id);
+struct party_data *party_searchname(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);
@@ -38,9 +38,9 @@ int party_send_message(struct map_session_data *sd,char *mes,int len);
int party_recv_message(int party_id,int account_id,char *mes,int len);
int party_check_conflict(struct map_session_data *sd);
int party_skill_check(struct map_session_data *sd, int party_id, int skillid, int skilllv);
-int party_send_xy_clear(struct party *p);
-int party_exp_share(struct party *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny);
-int party_share_loot(struct party *p, TBL_PC *sd, struct item *item_data);
+int party_send_xy_clear(struct party_data *p);
+int party_exp_share(struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny);
+int party_share_loot(struct party_data *p, TBL_PC *sd, struct item *item_data);
int party_send_dot_remove(struct map_session_data *sd);
int party_sub_count(struct block_list *bl, va_list ap);
int party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_session_data *sd,int type,...);
diff --git a/src/map/pc.c b/src/map/pc.c
index ff6a435cb..16baba08f 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -574,7 +574,6 @@ int pc_isequip(struct map_session_data *sd,int n)
*/
int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_time, struct mmo_charstatus *st)
{
- struct party *p;
struct guild *g;
int i;
unsigned long tick = gettick();
@@ -648,9 +647,6 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
sd->status.option &= OPTION_MASK;
sd->sc.option = sd->status.option; //This is the actual option used in battle.
- // パ?ティ??係の初期化
- sd->party_x = -1;
- sd->party_y = -1;
sd->guild_x = -1;
sd->guild_y = -1;
@@ -681,7 +677,7 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
intif_request_petdata(sd->status.account_id, sd->status.char_id, sd->status.pet_id);
// パ?ティ、ギルドデ?タの要求
- if (sd->status.party_id > 0 && (p = party_search(sd->status.party_id)) == NULL)
+ if (sd->status.party_id > 0 && party_search(sd->status.party_id) == NULL)
party_request_info(sd->status.party_id);
if (sd->status.guild_id > 0)
{
@@ -2621,7 +2617,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
int flag=0;
unsigned int tick = gettick();
struct map_session_data *first_sd = NULL,*second_sd = NULL,*third_sd = NULL;
- struct party *p=NULL;
+ struct party_data *p=NULL;
nullpo_retr(0, sd);
nullpo_retr(0, fitem);
@@ -2636,7 +2632,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
{
first_sd = map_id2sd(fitem->first_get_id);
if(DIFF_TICK(tick,fitem->first_get_tick) < 0) {
- if (!(p && p->item&1 &&
+ if (!(p && p->party.item&1 &&
first_sd && first_sd->status.party_id == sd->status.party_id
))
return 0;
@@ -2646,7 +2642,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
{
second_sd = map_id2sd(fitem->second_get_id);
if(DIFF_TICK(tick, fitem->second_get_tick) < 0) {
- if(!(p && p->item&1 &&
+ if(!(p && p->party.item&1 &&
((first_sd && first_sd->status.party_id == sd->status.party_id) ||
(second_sd && second_sd->status.party_id == sd->status.party_id))
))
@@ -2657,7 +2653,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
{
third_sd = map_id2sd(fitem->third_get_id);
if(DIFF_TICK(tick,fitem->third_get_tick) < 0) {
- if(!(p && p->item&1 &&
+ if(!(p && p->party.item&1 &&
((first_sd && first_sd->status.party_id == sd->status.party_id) ||
(second_sd && second_sd->status.party_id == sd->status.party_id) ||
(third_sd && third_sd->status.party_id == sd->status.party_id))
diff --git a/src/map/script.c b/src/map/script.c
index 8c84e89de..4bb550a13 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3159,7 +3159,7 @@ int buildin_warpparty(struct script_state *st)
int i;
unsigned short mapindex;
struct map_session_data *pl_sd;
- struct party *p=NULL;
+ struct party_data *p=NULL;
str=conv_str(st,& (st->stack->stack_data[st->start+2]));
x=conv_num(st,& (st->stack->stack_data[st->start+3]));
y=conv_num(st,& (st->stack->stack_data[st->start+4]));
@@ -3173,7 +3173,7 @@ int buildin_warpparty(struct script_state *st)
{
for (i = 0; i < MAX_PARTY; i++)
{
- if ((pl_sd = p->member[i].sd))
+ if ((pl_sd = p->data[i].sd))
{
if(map[pl_sd->bl.m].flag.nowarp)
continue;
@@ -3185,7 +3185,7 @@ int buildin_warpparty(struct script_state *st)
{
for (i = 0; i < MAX_PARTY; i++)
{
- if ((pl_sd = p->member[i].sd))
+ if ((pl_sd = p->data[i].sd))
{
if(map[pl_sd->bl.m].flag.noreturn)
continue;
@@ -3204,7 +3204,7 @@ int buildin_warpparty(struct script_state *st)
for (i = 0; i < MAX_PARTY; i++)
{
- if ((pl_sd = p->member[i].sd))
+ if ((pl_sd = p->data[i].sd))
{
if(map[pl_sd->bl.m].flag.noreturn)
continue;
@@ -3219,7 +3219,7 @@ int buildin_warpparty(struct script_state *st)
return 1;
for (i = 0; i < MAX_PARTY; i++)
{
- if ((pl_sd = p->member[i].sd))
+ if ((pl_sd = p->data[i].sd))
{
if(map[pl_sd->bl.m].flag.noreturn || map[pl_sd->bl.m].flag.nowarp)
continue;
@@ -4469,15 +4469,14 @@ int buildin_getcharid(struct script_state *st)
*/
char *buildin_getpartyname_sub(int party_id)
{
- struct party *p;
+ struct party_data *p;
- p=NULL;
p=party_search(party_id);
if(p!=NULL){
char *buf;
buf=(char *)aMallocA(NAME_LENGTH*sizeof(char));
- memcpy(buf, p->name, NAME_LENGTH-1);
+ memcpy(buf, p->party.name, NAME_LENGTH-1);
buf[NAME_LENGTH-1] = '\0';
return buf;
}
@@ -4504,10 +4503,9 @@ int buildin_getpartyname(struct script_state *st)
*/
int buildin_getpartymember(struct script_state *st)
{
- struct party *p;
+ struct party_data *p;
int i,j=0,type=0;
- p=NULL;
p=party_search(conv_num(st,& (st->stack->stack_data[st->start+2])));
if( st->end>st->start+3 )
@@ -4515,16 +4513,16 @@ int buildin_getpartymember(struct script_state *st)
if(p!=NULL){
for(i=0;i<MAX_PARTY;i++){
- if(p->member[i].account_id){
+ if(p->party.member[i].account_id){
switch (type) {
case 2:
- mapreg_setreg(add_str((unsigned char *) "$@partymemberaid")+(j<<24),p->member[i].account_id);
+ mapreg_setreg(add_str((unsigned char *) "$@partymemberaid")+(j<<24),p->party.member[i].account_id);
break;
case 1:
- mapreg_setreg(add_str((unsigned char *) "$@partymembercid")+(j<<24),p->member[i].char_id);
+ mapreg_setreg(add_str((unsigned char *) "$@partymembercid")+(j<<24),p->party.member[i].char_id);
break;
default:
- mapreg_setregstr(add_str((unsigned char *) "$@partymembername$")+(j<<24),p->member[i].name);
+ mapreg_setregstr(add_str((unsigned char *) "$@partymembername$")+(j<<24),p->party.member[i].name);
}
j++;
}