summaryrefslogtreecommitdiff
path: root/src/map/mapflag.cpp
blob: 4b7b305f2ddbaace4a9fbc08dd7984e1cb7b8aa1 (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
#include "mapflag.hpp"
//    mapflag.cpp - Implementation of map flag settings
//
//    Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
//
//    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 "../poison.hpp"

// because bitfields, that's why

bool MapFlags::get(MapFlag mf) const
{
    switch (mf)
    {
    case MapFlag::NOTELEPORT:
        return noteleport;
    case MapFlag::NORETURN:
        return noreturn;
    case MapFlag::MONSTER_NOTELEPORT:
        return monster_noteleport;
    case MapFlag::NOSAVE:
        return nosave;
    case MapFlag::NOPENALTY:
        return nopenalty;
    case MapFlag::PVP:
        return pvp;
    case MapFlag::PVP_NOPARTY:
        return pvp_noparty;
    case MapFlag::PVP_NOCALCRANK:
        return pvp_nocalcrank;
    case MapFlag::NOWARP:
        return nowarp;
    case MapFlag::NOWARPTO:
        return nowarpto;
    case MapFlag::NOPVP:
        return nopvp;
    case MapFlag::SNOW:
        return snow;
    case MapFlag::FOG:
        return fog;
    case MapFlag::SAKURA:
        return sakura;
    case MapFlag::LEAVES:
        return leaves;
    case MapFlag::RAIN:
        return rain;
    case MapFlag::NO_PLAYER_DROPS:
        return no_player_drops;
    case MapFlag::TOWN:
        return town;
    default:
        return false;
    }
}

void MapFlags::set(MapFlag mf, bool val)
{
    switch (mf)
    {
    case MapFlag::NOTELEPORT:
        noteleport = val;
        break;
    case MapFlag::NORETURN:
        noreturn = val;
        break;
    case MapFlag::MONSTER_NOTELEPORT:
        monster_noteleport = val;
        break;
    case MapFlag::NOSAVE:
        nosave = val;
        break;
    case MapFlag::NOPENALTY:
        nopenalty = val;
        break;
    case MapFlag::PVP:
        pvp = val;
        break;
    case MapFlag::PVP_NOPARTY:
        pvp_noparty = val;
        break;
    case MapFlag::PVP_NOCALCRANK:
        pvp_nocalcrank = val;
        break;
    case MapFlag::NOWARP:
        nowarp = val;
        break;
    case MapFlag::NOWARPTO:
        nowarpto = val;
        break;
    case MapFlag::NOPVP:
        nopvp = val;
        break;
    case MapFlag::SNOW:
        snow = val;
        break;
    case MapFlag::FOG:
        fog = val;
        break;
    case MapFlag::SAKURA:
        sakura = val;
        break;
    case MapFlag::LEAVES:
        leaves = val;
        break;
    case MapFlag::RAIN:
        rain = val;
        break;
    case MapFlag::NO_PLAYER_DROPS:
        no_player_drops = val;
        break;
    case MapFlag::TOWN:
        town = val;
        break;
    default:
        break;
    }
}

template<>
bool extract<MapFlag, void, void>(XString str, MapFlag *mf)
{
    const struct
    {
        char str[32];
        MapFlag id;
    } flags[] =
    {
        //{"alias", MapFlag::ALIAS},
        //{"nomemo", MapFlag::NOMEMO},
        {"noteleport", MapFlag::NOTELEPORT},
        {"noreturn", MapFlag::NORETURN},
        {"monster_noteleport", MapFlag::MONSTER_NOTELEPORT},
        {"nosave", MapFlag::NOSAVE},
        //{"nobranch", MapFlag::NOBRANCH},
        {"nopenalty", MapFlag::NOPENALTY},
        {"pvp", MapFlag::PVP},
        {"pvp_noparty", MapFlag::PVP_NOPARTY},
        //{"pvp_noguild", MapFlag::PVP_NOGUILD},
        //{"pvp_nightmaredrop", MapFlag::PVP_NIGHTMAREDROP},
        {"pvp_nocalcrank", MapFlag::PVP_NOCALCRANK},
        //{"gvg", MapFlag::GVG},
        //{"gvg_noparty", MapFlag::GVG_NOPARTY},
        //{"nozenypenalty", MapFlag::NOZENYPENALTY},
        //{"notrade", MapFlag::NOTRADE},
        //{"noskill", MapFlag::NOSKILL},
        {"nowarp", MapFlag::NOWARP},
        {"nowarpto", MapFlag::NOWARPTO},
        {"nopvp", MapFlag::NOPVP},
        //{"noicewall", MapFlag::NOICEWALL},
        {"snow", MapFlag::SNOW},
        {"fog", MapFlag::FOG},
        {"sakura", MapFlag::SAKURA},
        {"leaves", MapFlag::LEAVES},
        {"rain", MapFlag::RAIN},
        {"no_player_drops", MapFlag::NO_PLAYER_DROPS},
        {"town", MapFlag::TOWN},
    };
    for (auto& pair : flags)
        if (str == pair.str)
        {
            *mf = pair.id;
            return true;
        }
    return false;
}