summaryrefslogtreecommitdiff
path: root/src/map/party.c
blob: ded5626f0586f8e6b36a4d2350a7b5b3bffc8df9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "../common/timer.h"
#include "../common/socket.h"
#include "../common/nullpo.h"
#include "../common/malloc.h"
#include "../common/showmsg.h"

#include "party.h"
#include "pc.h"
#include "map.h"
#include "battle.h"
#include "intif.h"
#include "clif.h"
#include "log.h"
#include "skill.h"
#include "status.h"

#define PARTY_SEND_XY_INVERVAL	1000	// ���W��g�o���M�̊Ԋu

static struct dbt* party_db;
static struct party* 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);
/*==========================================
 * �I��
 *------------------------------------------
 */
void do_final_party(void)
{
	party_db->destroy(party_db,NULL);
}
// ������
void do_init_party(void)
{
	party_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int));
	add_timer_func_list(party_send_xy_timer,"party_send_xy_timer");
	add_timer_interval(gettick()+PARTY_SEND_XY_INVERVAL,party_send_xy_timer,0,0,PARTY_SEND_XY_INVERVAL);
}

// ����
struct party *party_search(int party_id)
{
	if (party_cache && party_cache->party_id == party_id)
		return party_cache;

	party_cache = idb_get(party_db,party_id);
	return party_cache;
}
int party_searchname_sub(DBKey key,void *data,va_list ap)
{
	struct party *p=(struct party *)data,**dst;
	char *str;
	str=va_arg(ap,char *);
	dst=va_arg(ap,struct party **);
	if(strncmpi(p->name,str,NAME_LENGTH)==0)
		*dst=p;
	return 0;
}
// �p�[�e�B������
struct party* party_searchname(char *str)
{
	struct party *p=NULL;
	party_db->foreach(party_db,party_searchname_sub,str,&p);
	return p;
}
// �쐬�v��
int party_create(struct map_session_data *sd,char *name,int item,int item2)
{
	nullpo_retr(0, sd);

	if(sd->status.party_id==0)
		intif_create_party(sd,name,item,item2);
	else
		clif_party_created(sd,2);
	return 0;
}

// �쐬�”�
int party_created(int account_id,int char_id,int fail,int party_id,char *name)
{
	struct map_session_data *sd;
	sd=map_id2sd(account_id);

	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{
		clif_party_created(sd,1);
	}
	return 0;
}

// ���v��
int party_request_info(int party_id)
{
	return intif_request_partyinfo(party_id);
}

// �����L�����̊m�F
int party_check_member(struct party *p)
{
	int i, users;
	struct map_session_data *sd, **all_sd;

	nullpo_retr(0, p);

	all_sd = map_getallusers(&users);
	
	for(i=0;i<users;i++)
	{
		if((sd = all_sd[i]) && sd->status.party_id==p->party_id)
		{
			int j,f=1;
			for(j=0;j<MAX_PARTY;j++){
				if(p->member[j].account_id==sd->status.account_id && 
					p->member[j].char_id==sd->status.char_id)
				{
					f=0;
					break;
				}
			}
			
			if(f){
				sd->status.party_id=0;
				if(battle_config.error_log)
					ShowWarning("party: check_member %d[%s] is not member\n",sd->status.account_id,sd->status.name);
			}
		}
	}
	return 0;
}

// ��񏊓����s�i����ID�̃L������S���������ɂ���j
int party_recv_noinfo(int party_id)
{
	int i, users;
	struct map_session_data *sd, **all_sd;

	all_sd = map_getallusers(&users);
	
	for(i=0;i<users;i++){
		if((sd = all_sd[i]) && sd->status.party_id==party_id)
			sd->status.party_id=0;
	}
	return 0;
}

static void* create_party(DBKey key, va_list args) {
	struct party *p;
	p=(struct party *)aCalloc(1,sizeof(struct party));
	return p;
}
// ��񏊓�
int party_recv_info(struct party *sp)
{
	struct map_session_data *sd;
	struct party *p;
	int i;
	
	nullpo_retr(0, sp);

	p= idb_ensure(party_db, sp->party_id, create_party);
	if (!p->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;
			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++){	// �ݒ���̑��M
		sd = p->member[i].sd;
		if(!sd)
			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;
		}
	}
	
	return 0;
}

// �p�[�e�B�ւ̊��U
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);
	int i,flag=0;
	
	nullpo_retr(0, sd);

	if(tsd==NULL || p==NULL)
		return 0;
	if(!battle_config.invite_request_check) {
		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 ){	// ����̏����m�F
		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.
			flag = 1;
		if(p->member[i].account_id==account_id && p->member[i].char_id==tsd->status.char_id){
			clif_party_inviteack(sd,tsd->status.name,0);
			return 0;
		}
	}
	if (!flag) { //Full party.
		clif_party_inviteack(sd,tsd->status.name,2);
		return 0;
	}
		
	tsd->party_invite=sd->status.party_id;
	tsd->party_invite_account=sd->status.account_id;

	clif_party_invite(sd,tsd);
	return 1;
}
// �p�[�e�B���U�ւ̕ԓ�
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�I�֒lj��v��
		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;
}
// �p�[�e�B���lj����ꂽ
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;
	
	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); // �L���������o�^�����������������E���v�����o��
		}
		return 0;
	}
	
	sd->party_invite=0;
	sd->party_invite_account=0;
	
	sd2=map_id2sd(sd->party_invite_account);
	if (sd2)
		clif_party_inviteack(sd2,sd->status.name,flag?2:0);
	if(flag)
		return 0;
	
	sd->state.party_sent=0;
	sd->status.party_id=party_id;

	party_check_conflict(sd);
	clif_charnameupdate(sd); //Update char name's display [Skotlex]
	clif_party_hp(sd);
	clif_party_xy(sd);
	return 0;
}
// �p�[�e�B�����v��
int party_removemember(struct map_session_data *sd,int account_id,char *name)
{
	struct party *p;
	int i;

	nullpo_retr(0, sd);
	
	if( (p = party_search(sd->status.party_id)) == NULL )
		return 0;

	for(i=0;i<MAX_PARTY;i++){	// ���[�_�[���ǂ����`�F�b�N
		if(p->member[i].account_id==sd->status.account_id && p->member[i].char_id==sd->status.char_id) {
			if(p->member[i].leader)
				break;
			return 0;
		}
	}
	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)
		{
			intif_party_leave(p->party_id,account_id,p->member[i].char_id);
			return 1;
		}
	}
	return 0;
}

// �p�[�e�B�E�ޗv��
int party_leave(struct map_session_data *sd)
{
	struct party *p;
	int i;

	nullpo_retr(0, 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);
			return 0;
		}
	}
	return 0;
}
// �p�[�e�B�����o���E�ނ���
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);
	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(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]
	}
	return 0;
}
// �p�[�e�B���U�ʒm
int party_broken(int party_id)
{
	struct party *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 (party_cache && party_cache->party_id == party_id)
		party_cache = NULL;
	idb_remove(party_db,party_id);
	return 0;
}
// �p�[�e�B�̐ݒ�ύX�v��
int party_changeoption(struct map_session_data *sd,int exp,int flag)
{
	nullpo_retr(0, sd);

	if( sd->status.party_id==0)
		return 0;
	intif_party_changeoption(sd->status.party_id,sd->status.account_id,exp,flag);
	return 0;
}
// �p�[�e�B�̐ݒ�ύX�ʒm
int party_optionchanged(int party_id,int account_id,int exp,int item,int flag)
{
	struct party *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;
	clif_party_option(p,sd,flag);
	return 0;
}

// �p�[�e�B�����o�̈ړ��ʒm
int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv)
{
	struct party *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;
		}
		*/
		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;
			}
			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);
		return 0;
	}
	
	clif_party_info(p,-1);
	return 0;
}

// �p�[�e�B�����o�̈ړ�
int party_send_movemap(struct map_session_data *sd)
{
	struct party *p;

	nullpo_retr(0, sd);

	if( sd->status.party_id==0 )
		return 0;
	intif_party_changemap(sd,1);

	if( sd->state.party_sent )	// �����p�[�e�B�f�[�^�͑��M�ς�
		return 0;

	// �����m�F	
	party_check_conflict(sd);
	
	// ����Ȃ�p�[�e�B��񑗐M
	if( (p=party_search(sd->status.party_id))!=NULL ){
		party_check_member(p);	// �������m�F����
		if(sd->status.party_id==p->party_id){
			clif_party_main_info(p,sd->fd);
			clif_party_option(p,sd,0x100);
			clif_party_info(p,sd->fd);
			sd->state.party_sent=1;
		}
	}
	
	return 0;
}
// �p�[�e�B�����o�̃��O�A�E�g
int party_send_logout(struct map_session_data *sd)
{
	struct party *p;

	nullpo_retr(0, sd);

	if( sd->status.party_id>0 )
		intif_party_changemap(sd,0);
	
	// sd�������ɂȂ�̂Ńp�[�e�B��񂩂�폜
	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;
	}
	
	return 0;
}
// �p�[�e�B���b�Z�[�W���M
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);
	//Chat Logging support Type 'P'
	if(log_config.chat&1 //we log everything then
		|| ( 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;
}

// �p�[�e�B���b�Z�[�W��M
int party_recv_message(int party_id,int account_id,char *mes,int len)
{
	struct party *p;
	if( (p=party_search(party_id))==NULL)
		return 0;
	clif_party_message(p,account_id,mes,len);
	return 0;
}
// �p�[�e�B�����m�F
int party_check_conflict(struct map_session_data *sd)
{
	nullpo_retr(0, sd);

	intif_party_checkconflict(sd->status.party_id,sd->status.account_id,sd->status.char_id);
	return 0;
}

int party_skill_check(struct map_session_data *sd, int party_id, int skillid, int skilllv)
{
	struct party *p;
	struct map_session_data *p_sd;
	int i;

	if(!party_id || (p=party_search(party_id))==NULL)
		return 0;
	for(i=0;i<MAX_PARTY;i++){
		if ((p_sd = p->member[i].sd) == NULL)
			continue;
		switch(skillid) {
			case TK_COUNTER: //Increase Triple Attack rate of Monks.
				if((p_sd->class_&MAPID_UPPERMASK) == MAPID_MONK
					&& sd->bl.m == p_sd->bl.m
					&& pc_checkskill(p_sd,MO_TRIPLEATTACK)) {
					int rate = 50 +50*skilllv; //+100/150/200% success rate
					status_change_start(&p_sd->bl,SC_SKILLRATE_UP,MO_TRIPLEATTACK,rate,0,0,skill_get_time(SG_FRIEND, 1),0);
				}
				break;
			case MO_TRIPLEATTACK: //Increase Counter rate of Star Gladiators
				if((p_sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR
					&& sd->bl.m == p_sd->bl.m
					&& pc_checkskill(p_sd,TK_COUNTER)) {
					int rate = 50 +50*pc_checkskill(p_sd,TK_COUNTER); //+100/150/200% success rate
					status_change_start(&p_sd->bl,SC_SKILLRATE_UP,TK_COUNTER,rate,0,0,skill_get_time(SG_FRIEND, 1),0);
				}
				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;
}

// �ʒu��g�o�ʒm�p
int party_send_xy_timer_sub(DBKey key,void *data,va_list ap)
{
	struct party *p=(struct party *)data;
	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){
			// ���W�ʒm
			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;
			}
		}
	}
	return 0;
}
// �ʒu��g�o�ʒm
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;
}

// �ʒu�ʒm�N���A
int party_send_xy_clear(struct party *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;
		}
	}
	return 0;
}

// exp share and added zeny share [Valaris]
int party_exp_share(struct party *p,int map,int base_exp,int job_exp,int zeny)
{
	struct map_session_data* sd[MAX_PARTY];
	int i;
	short c, bonus =100; // modified [Valaris]
	unsigned long base, job;

	nullpo_retr(0, p);

	for (i = c = 0; i < MAX_PARTY; i++)
		if ((sd[c] = p->member[i].sd)!=NULL && sd[c]->bl.m == map && !pc_isdead(sd[c])) {
			if (battle_config.idle_no_share && (pc_issit(sd[c]) || sd[c]->chatID || (sd[c]->idletime < (last_tick - battle_config.idle_no_share))))
				continue;
			c++;
		}
	if (c < 1)
		return 0;
	if (battle_config.party_even_share_bonus) //Valaris's even share exp bonus equation.
		bonus += (battle_config.party_even_share_bonus*c*(c-1)/10);	//Changed Valaris's bonus switch to an equation [Skotlex]
	else	//Official kRO/iRO sites state that the even share bonus is 10% per additional party member.
		bonus += (c-1)*10;
	base = (unsigned long)(base_exp/c)*bonus/100;
	job = (unsigned long)(job_exp/c)*bonus/100;
	if (base > 0x7fffffff)
		base = 0x7fffffff;
	if (job > 0x7fffffff)
		job = 0x7fffffff;
	for (i = 0; i < c; i++)
	{
		pc_gainexp(sd[i], base, job);
		if (battle_config.zeny_from_mobs) // zeny from mobs [Valaris]
			pc_getzeny(sd[i],bonus*zeny/(c*100));
	}
	return 0;
}

int party_send_dot_remove(struct map_session_data *sd)
{
	if (sd->status.party_id)
		clif_party_xy_remove(sd);
	return 0;
}

// To use for Taekwon's "Fighting Chant"
// int c = 0;
// party_foreachsamemap(party_sub_count, sd, 0, &c);
int party_sub_count(struct block_list *bl, va_list ap)
{
	int *c = va_arg(ap, int*);

	(*c)++;
	return 1;
}

// �����}�b�v�̃p�[�e�B�����o�[�S�̂ɏ�����������
// type==0 �����}�b�v
//     !=0 ��ʓ�
void party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_session_data *sd,int type,...)
{
	struct party *p;
	va_list ap;
	int i;
	int x0,y0,x1,y1;
	struct block_list *list[MAX_PARTY];
	int blockcount=0;
	
	nullpo_retv(sd);
	
	if((p=party_search(sd->status.party_id))==NULL)
		return;

	x0=sd->bl.x-AREA_SIZE;
	y0=sd->bl.y-AREA_SIZE;
	x1=sd->bl.x+AREA_SIZE;
	y1=sd->bl.y+AREA_SIZE;

	va_start(ap,type);
	
	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(type!=0 &&
				(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; 
		}
	}

	map_freeblock_lock();	// ����������̉�����֎~����
	
	for(i=0;i<blockcount;i++)
		if(list[i]->prev)	// �L�����ǂ����`�F�b�N
			func(list[i],ap);

	map_freeblock_unlock();	// ��������‚���

	va_end(ap);
}