summaryrefslogtreecommitdiff
path: root/src/map/party.cpp
blob: f40b99183dbd5c0d82f5d6645835665d5a943fae (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
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
#include "party.hpp"
//    party.cpp - Small groups of temporary allies.
//
//    Copyright © ????-2004 Athena Dev Teams
//    Copyright © 2004-2011 The Mana World Development Team
//    Copyright © 2011-2014 Ben Longbons <b.r.longbons@gmail.com>
//    Copyright © 2013 Freeyorp
//
//    This file is part of The Mana World (Athena server)
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include "../compat/nullpo.hpp"

#include "../strings/xstring.hpp"

#include "../generic/db.hpp"

#include "../io/cxxstdio.hpp"

#include "../net/timer.hpp"

#include "../mmo/ids.hpp"
#include "../mmo/mmo.hpp"

#include "battle.hpp"
#include "clif.hpp"
#include "intif.hpp"
#include "map.hpp"
#include "pc.hpp"

#include "../poison.hpp"

// 座標やHP送信の間隔
constexpr interval_t PARTY_SEND_XYHP_INVERVAL = std::chrono::seconds(1);

static
Map<PartyId, struct party> party_db;

static
void party_check_conflict(dumb_ptr<map_session_data> sd);
static
void party_send_xyhp_timer(TimerData *tid, tick_t tick);

// 初期化
void do_init_party(void)
{
    Timer(gettick() + PARTY_SEND_XYHP_INVERVAL,
            party_send_xyhp_timer,
            PARTY_SEND_XYHP_INVERVAL
    ).detach();
}

// 検索
struct party *party_search(PartyId party_id)
{
    return party_db.search(party_id);
}

static
void party_searchname_sub(struct party *p, PartyName str, struct party **dst)
{
    if (p->name == str)
        *dst = p;
}

// パーティ名検索
struct party *party_searchname(PartyName str)
{
    struct party *p = NULL;
    for (auto& pair : party_db)
        party_searchname_sub(&pair.second, str, &p);
    return p;
}

/* Process a party creation request. */
int party_create(dumb_ptr<map_session_data> sd, PartyName name)
{
    nullpo_ret(sd);

    name = stringish<PartyName>(name.strip());

    /* The party name is empty/invalid. */
    if (!name)
        clif_party_created(sd, 1);

    /* Make sure the character isn't already in a party. */
    if (!sd->status.party_id)
        intif_create_party(sd, name);
    else
        clif_party_created(sd, 2);

    return 0;
}

/* Relay the result of a party creation request. */
void party_created(AccountId account_id, int fail, PartyId party_id, PartyName name)
{
    dumb_ptr<map_session_data> sd;
    sd = map_id2sd(account_to_block(account_id));

    nullpo_retv(sd);

    /* The party name is valid and not already taken. */
    if (!fail)
    {
        sd->status.party_id = party_id;

        struct party *p = party_db.search(party_id);
        if (p != NULL)
        {
            PRINTF("party_created(): ID already exists!\n"_fmt);
            exit(1);
        }

        p = party_db.init(party_id);
        p->party_id = party_id;
        p->name = name;

        /* The party was created successfully. */
        clif_party_created(sd, 0);
    }

    else
        clif_party_created(sd, 1);
}

// 情報要求
void party_request_info(PartyId party_id)
{
    intif_request_partyinfo(party_id);
}

// 所属キャラの確認
static
int party_check_member(struct party *p)
{
    nullpo_ret(p);

    for (io::FD i : iter_fds())
    {
        Session *s = get_session(i);
        if (!s)
            continue;
        map_session_data *sd = static_cast<map_session_data *>(s->session_data.get());
        if (sd && sd->state.auth)
        {
            if (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_key.account_id)
                    {
                        if (p->member[j].name == sd->status_key.name)
                            f = 0;  // データがある
                        else
                        {
                            // I can prove it was already zeroed
                            // p->member[j].sd = NULL; // 同垢別キャラだった
                        }
                    }
                }
                if (f)
                {
                    sd->status.party_id = PartyId();
                    if (battle_config.error_log)
                        PRINTF("party: check_member %d[%s] is not member\n"_fmt,
                                sd->status_key.account_id, sd->status_key.name);
                }
            }
        }
    }
    return 0;
}

// 情報所得失敗(そのIDのキャラを全部未所属にする)
int party_recv_noinfo(PartyId party_id)
{
    for (io::FD i : iter_fds())
    {
        Session *s = get_session(i);
        if (!s)
            continue;
        map_session_data *sd = static_cast<map_session_data *>(s->session_data.get());
        if (sd && sd->state.auth)
        {
            if (sd->status.party_id == party_id)
                sd->status.party_id = PartyId();
        }
    }
    return 0;
}

// 情報所得
int party_recv_info(const struct party *sp)
{
    int i;

    nullpo_ret(sp);

    struct party *p = party_db.search(sp->party_id);
    if (p == NULL)
    {
        p = party_db.init(sp->party_id);

        // 最初のロードなのでユーザーのチェックを行う
        *p = *sp;
        party_check_member(p);
    }
    else
        *p = *sp;

    for (i = 0; i < MAX_PARTY; i++)
    {                           // sdの設定
        dumb_ptr<map_session_data> sd = map_id2sd(account_to_block(p->member[i].account_id));
        p->member[i].sd = (sd != NULL
                           && sd->status.party_id == p->party_id) ? sd.operator->() : NULL;
    }

    clif_party_info(p, nullptr);

    for (i = 0; i < MAX_PARTY; i++)
    {                           // 設定情報の送信
//      dumb_ptr<map_session_data> sd = map_id2sd(p->member[i].account_id);
        dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(p->member[i].sd);
        if (sd != NULL && sd->party_sended == 0)
        {
            clif_party_option(p, sd, 0x100);
            sd->party_sended = 1;
        }
    }

    return 0;
}

/* Process party invitation from sd to account_id. */
int party_invite(dumb_ptr<map_session_data> sd, AccountId account_id)
{
    dumb_ptr<map_session_data> tsd = map_id2sd(account_to_block(account_id));
    struct party *p = party_search(sd->status.party_id);
    int i;
    int full = 1; /* Indicates whether or not there's room for one more. */

    nullpo_ret(sd);

    if (!tsd || !p || !tsd->sess)
        return 0;

    if (!battle_config.invite_request_check)
    {
        /* Disallow the invitation under these conditions. */
        if (tsd->trade_partner || tsd->npc_id
            || tsd->npc_shopid || pc_checkskill(tsd, SkillID::NV_PARTY) < 1)
        {
            clif_party_inviteack(sd, tsd->status_key.name, 1);
            return 0;
        }
    }

    /* The target player is already in a party, or has a pending invitation. */
    if (tsd->status.party_id || tsd->party_invite)
    {
        clif_party_inviteack(sd, tsd->status_key.name, 0);
        return 0;
    }

    for (i = 0; i < MAX_PARTY; i++)
    {
        /*
         * A character from the target account is already in the same party.
         * The response isn't strictly accurate, as they're separate
         * characters, but we're making do with what was already in place and
         * leaving this (mostly) alone for now.
         */
        if (p->member[i].account_id == account_id)
        {
            clif_party_inviteack(sd, tsd->status_key.name, 1);
            return 0;
        }

        if (!p->member[i].account_id)
            full = 0;
    }

    /* There isn't enough room for a new member. */
    if (full)
    {
        clif_party_inviteack(sd, tsd->status_key.name, 3);
        return 0;
    }

    /* Otherwise, relay the invitation to the target player. */
    tsd->party_invite = sd->status.party_id;
    tsd->party_invite_account = sd->status_key.account_id;

    clif_party_invite(sd, tsd);
    return 0;
}

/* Process response to party invitation. */
int party_reply_invite(dumb_ptr<map_session_data> sd, AccountId account_id, int flag)
{
    nullpo_ret(sd);

    /* There is no pending invitation. */
    if (!sd->party_invite || !sd->party_invite_account)
        return 0;

    /*
     * Only one invitation can be pending, so these have to be the same. Since
     * the client continues to send the wrong ID, and it's already managed on
     * this side of things, the sent ID is being ignored.
     */
    account_id = sd->party_invite_account;

    /* The invitation was accepted. */
    if (flag == 1)
        intif_party_addmember(sd->party_invite, sd->status_key.account_id);
    /* The invitation was rejected. */
    else
    {
        /* This is the player who sent the invitation. */
        dumb_ptr<map_session_data> tsd = NULL;

        sd->party_invite = PartyId();
        sd->party_invite_account = AccountId();

        if ((tsd = map_id2sd(account_to_block(account_id))))
            clif_party_inviteack(tsd, sd->status_key.name, 1);
    }
    return 0;
}

// パーティが追加された
int party_member_added(PartyId party_id, AccountId account_id, int flag)
{
    dumb_ptr<map_session_data> sd = map_id2sd(account_to_block(account_id)), sd2;
    struct party *p = party_search(party_id);

    if (sd == NULL)
    {
        if (flag == 0)
        {
            if (battle_config.error_log)
                PRINTF("party: member added error %d is not online\n"_fmt,
                        account_id);
            intif_party_leave(party_id, account_id);   // キャラ側に登録できなかったため脱退要求を出す
        }
        return 0;
    }
    sd2 = map_id2sd(account_to_block(sd->party_invite_account));
    sd->party_invite = PartyId();
    sd->party_invite_account = AccountId();

    if (p == NULL)
    {
        PRINTF("party_member_added: party %d not found.\n"_fmt, party_id);
        intif_party_leave(party_id, account_id);
        return 0;
    }

    if (flag == 1)
    {                           // 失敗
        if (sd2 != NULL)
            clif_party_inviteack(sd2, sd->status_key.name, 0);
        return 0;
    }

    // 成功
    sd->party_sended = 0;
    sd->status.party_id = party_id;

    if (sd2 != NULL)
        clif_party_inviteack(sd2, sd->status_key.name, 2);

    // いちおう競合確認
    party_check_conflict(sd);

    party_send_xy_clear(p);

    return 0;
}

// パーティ除名要求
int party_removemember(dumb_ptr<map_session_data> sd, AccountId account_id)
{
    struct party *p;
    int i;

    nullpo_ret(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_key.account_id)
            if (p->member[i].leader == 0)
                return 0;
    }

    for (i = 0; i < MAX_PARTY; i++)
    {                           // 所属しているか調べる
        if (p->member[i].account_id == account_id)
        {
            intif_party_leave(p->party_id, account_id);
            return 0;
        }
    }
    return 0;
}

// パーティ脱退要求
int party_leave(dumb_ptr<map_session_data> sd)
{
    struct party *p;
    int i;

    nullpo_ret(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_key.account_id)
        {
            intif_party_leave(p->party_id, sd->status_key.account_id);
            return 0;
        }
    }
    return 0;
}

// パーティメンバが脱退した
int party_member_leaved(PartyId party_id, AccountId account_id, CharName name)
{
    dumb_ptr<map_session_data> sd = map_id2sd(account_to_block(account_id));
    struct party *p = party_search(party_id);
    if (p != NULL)
    {
        int i;
        for (i = 0; i < MAX_PARTY; i++)
            if (p->member[i].account_id == account_id)
            {
                clif_party_leaved(p, sd, account_id, name, 0x00);
                p->member[i].account_id = AccountId();
                p->member[i].sd = NULL;
            }
    }
    if (sd != NULL && sd->status.party_id == party_id)
    {
        sd->status.party_id = PartyId();
        sd->party_sended = 0;
    }
    return 0;
}

// パーティ解散通知
int party_broken(PartyId 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, dumb_ptr<map_session_data>(p->member[i].sd),
                               p->member[i].account_id, p->member[i].name,
                               0x10);
            p->member[i].sd->status.party_id = PartyId();
            p->member[i].sd->party_sended = 0;
        }
    }
    party_db.erase(party_id);
    return 0;
}

// パーティの設定変更要求
int party_changeoption(dumb_ptr<map_session_data> sd, int exp, int item)
{
    struct party *p;

    nullpo_ret(sd);

    if (!sd->status.party_id
        || (p = party_search(sd->status.party_id)) == NULL)
        return 0;
    intif_party_changeoption(sd->status.party_id, sd->status_key.account_id, exp,
                              item);
    return 0;
}

// パーティの設定変更通知
int party_optionchanged(PartyId party_id, AccountId account_id, int exp, int item,
                         int flag)
{
    struct party *p;
    dumb_ptr<map_session_data> sd = map_id2sd(account_to_block(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;
}

// パーティメンバの移動通知
void party_recv_movemap(PartyId party_id, AccountId account_id, MapName mapname,
        int online, int lv)
{
    struct party *p;
    int i;
    if ((p = party_search(party_id)) == NULL)
        return;
    for (i = 0; i < MAX_PARTY; i++)
    {
        struct party_member *m = &p->member[i];
        if (m == NULL)
        {
            PRINTF("party_recv_movemap nullpo?\n"_fmt);
            return;
        }
        if (m->account_id == account_id)
        {
            m->map = mapname;
            m->online = online;
            m->lv = lv;
            break;
        }
    }
    if (i == MAX_PARTY)
    {
        if (battle_config.error_log)
            PRINTF("party: not found member %d on %d[%s]"_fmt, account_id,
                    party_id, p->name);
        return;
    }

    for (i = 0; i < MAX_PARTY; i++)
    {                           // sd再設定
        dumb_ptr<map_session_data> sd = map_id2sd(account_to_block(p->member[i].account_id));
        p->member[i].sd = (sd != NULL
                           && sd->status.party_id == p->party_id) ? sd.operator->() : NULL;
    }

    party_send_xy_clear(p);    // 座標再通知要請

    clif_party_info(p, nullptr);
}

// パーティメンバの移動
int party_send_movemap(dumb_ptr<map_session_data> sd)
{
    struct party *p;

    nullpo_ret(sd);

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

    if (sd->party_sended != 0)  // もうパーティデータは送信済み
        return 0;

    // 競合確認
    party_check_conflict(sd);

    // あるならパーティ情報送信
    if ((p = party_search(sd->status.party_id)) != NULL)
    {
        party_check_member(p); // 所属を確認する
        if (sd->status.party_id == p->party_id)
        {
            clif_party_info(p, sd->sess);
            clif_party_option(p, sd, 0x100);
            sd->party_sended = 1;
        }
    }

    return 0;
}

// パーティメンバのログアウト
int party_send_logout(dumb_ptr<map_session_data> sd)
{
    struct party *p;

    nullpo_ret(sd);

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

    // sdが無効になるのでパーティ情報から削除
    if ((p = party_search(sd->status.party_id)) != NULL)
    {
        int i;
        for (i = 0; i < MAX_PARTY; i++)
            if (dumb_ptr<map_session_data>(p->member[i].sd) == sd)
                p->member[i].sd = NULL;
    }

    return 0;
}

// パーティメッセージ送信
void party_send_message(dumb_ptr<map_session_data> sd, XString mes)
{
    if (!sd->status.party_id)
        return;
    intif_party_message(sd->status.party_id, sd->status_key.account_id, mes);
}

// パーティメッセージ受信
void party_recv_message(PartyId party_id, AccountId account_id, XString mes)
{
    struct party *p;
    if ((p = party_search(party_id)) == NULL)
        return;
    clif_party_message(p, account_id, mes);
}

// パーティ競合確認
void party_check_conflict(dumb_ptr<map_session_data> sd)
{
    nullpo_retv(sd);

    intif_party_checkconflict(sd->status.party_id,
            sd->status_key.account_id, sd->status_key.name);
}

// 位置やHP通知用
static
void party_send_xyhp_timer_sub(struct party *p)
{
    int i;

    nullpo_retv(p);

    for (i = 0; i < MAX_PARTY; i++)
    {
        dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(p->member[i].sd);
        if (sd != NULL)
        {
            // 座標通知
            if (sd->party_x != sd->bl_x || sd->party_y != sd->bl_y)
            {
                clif_party_xy(p, sd);
                sd->party_x = sd->bl_x;
                sd->party_y = sd->bl_y;
            }
            // HP通知
            if (sd->party_hp != sd->status.hp)
            {
                clif_party_hp(p, sd);
                sd->party_hp = sd->status.hp;
            }

        }
    }
}

// 位置やHP通知
void party_send_xyhp_timer(TimerData *, tick_t)
{
    for (auto& pair : party_db)
        party_send_xyhp_timer_sub(&pair.second);
}

// 位置通知クリア
void party_send_xy_clear(struct party *p)
{
    int i;

    nullpo_retv(p);

    for (i = 0; i < MAX_PARTY; i++)
    {
        dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(p->member[i].sd);
        if (sd != NULL)
        {
            sd->party_x = -1;
            sd->party_y = -1;
            sd->party_hp = -1;
        }
    }
}

// HP通知の必要性検査用(map_foreachinmoveareaから呼ばれる)
void party_send_hp_check(dumb_ptr<block_list> bl, PartyId party_id, int *flag)
{
    dumb_ptr<map_session_data> sd;

    nullpo_retv(bl);
    sd = bl->is_player();

    if (sd->status.party_id == party_id)
    {
        *flag = 1;
        sd->party_hp = -1;
    }
}

// 経験値公平分配
int party_exp_share(struct party *p, map_local *mapid, int base_exp, int job_exp)
{
    dumb_ptr<map_session_data> sd;
    int i, c;

    nullpo_ret(p);

    for (i = c = 0; i < MAX_PARTY; i++)
    {
        sd = dumb_ptr<map_session_data>(p->member[i].sd);
        if (sd != NULL && sd->bl_m == mapid)
            c++;
    }
    if (c == 0)
        return 0;
    for (i = 0; i < MAX_PARTY; i++)
    {
        sd = dumb_ptr<map_session_data>(p->member[i].sd);
        if (sd != NULL && sd->bl_m == mapid)
            pc_gainexp_reason(sd, base_exp / c + 1, job_exp / c + 1,
            PC_GAINEXP_REASON::SHARING);
    }
    return 0;
}

// 同じマップのパーティメンバー全体に処理をかける
// type==0 同じマップ
//     !=0 画面内
void party_foreachsamemap(std::function<void(dumb_ptr<block_list>)> func,
        dumb_ptr<map_session_data> sd, int type)
{
    struct party *p;
    int i;
    int x0, y0, x1, y1;
    dumb_ptr<map_session_data> 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;

    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++] = dumb_ptr<map_session_data>(m->sd);
        }
    }

    MapBlockLock lock;

    for (i = 0; i < blockcount; i++)
        if (list[i]->bl_prev)      // 有効かどうかチェック
            func(list[i]);
}