summaryrefslogtreecommitdiff
path: root/src/map/party.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-10 03:58:15 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-10 03:58:15 +0000
commite2856893e1bdaba52c1ff3e0cbd7a4635e7af90b (patch)
tree2bb49221533209ffdbb7e9cecb107fc734d57872 /src/map/party.c
parent8542722b5f295eb8d282cc22f894ec49b5368f40 (diff)
downloadhercules-e2856893e1bdaba52c1ff3e0cbd7a4635e7af90b.tar.gz
hercules-e2856893e1bdaba52c1ff3e0cbd7a4635e7af90b.tar.bz2
hercules-e2856893e1bdaba52c1ff3e0cbd7a4635e7af90b.tar.xz
hercules-e2856893e1bdaba52c1ff3e0cbd7a4635e7af90b.zip
- Added structure party_data and party_member_data to the map server to hold party-specific required information about parties including Monk/TK/SG/SN states and party member count.
- party Hp updates are no longer done each time the Hp is modified, but together with the party xy timer. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7083 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/party.c')
-rw-r--r--src/map/party.c460
1 files changed, 229 insertions, 231 deletions
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;