summaryrefslogtreecommitdiff
path: root/src/emap/battleground.c
blob: c22d7339fdb0268b8938f04f93c9b7d9f3c4ce73 (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
// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// Copyright (c) 2014 - 2015 Evol developers

#include "common/hercules.h"

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

#include "common/db.h"
#include "common/HPMi.h"
#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/socket.h"
#include "common/strlib.h"
#include "common/timer.h"
#include "map/battleground.h"
#include "map/itemdb.h"
#include "map/map.h"
#include "map/pc.h"

#include "emap/data/bgd.h"
#include "emap/data/session.h"
#include "emap/struct/bgdext.h"
#include "emap/struct/sessionext.h"

bool ebg_team_warp_pre(int *bg_idPtr,
                       unsigned short *map_index,
                       short *x,
                       short *y)
{
    int i;
    int bg_id = *bg_idPtr;
    struct battleground_data *bgd = bg->team_search(bg_id);
    if (bgd == NULL)
        return false;
    struct BgdExt *bdata = bgd_get(bgd);
    if (!bdata)
    {
        ShowWarning("bdata empty\n");
        return true;
    }
    for (i = 0; i < MAX_BG_MEMBERS; i++)
    {
        TBL_PC *sd = bgd->members[i].sd;
        if (sd != NULL)
        {
            struct SessionExt *sdata = session_get_bysd(sd);
            if (sdata)
                sdata->teamId = bdata->teamId;
            pc->setpos(bgd->members[i].sd, *map_index, *x, *y, CLR_TELEPORT);
        }
    }
    return true;
}