summaryrefslogtreecommitdiff
path: root/src/net/tmwa/beinghandler.cpp
blob: 2ec3e62cb966b314230ca7a25cfca7b654d566e7 (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
/*
 *  The ManaPlus Client
 *  Copyright (C) 2004-2009  The Mana World Development Team
 *  Copyright (C) 2009-2010  The Mana Developers
 *  Copyright (C) 2011-2015  The ManaPlus Developers
 *
 *  This file is part of The ManaPlus Client.
 *
 *  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 2 of the License, or
 *  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 "net/tmwa/beinghandler.h"

#include "actormanager.h"
#include "effectmanager.h"
#include "guild.h"
#include "party.h"

#include "being/localplayer.h"

#include "particle/particle.h"

#include "input/keyboardconfig.h"

#include "gui/windows/outfitwindow.h"
#include "gui/windows/socialwindow.h"

#include "net/serverfeatures.h"

#include "net/ea/beingnet.h"

#include "net/tmwa/beingnet.h"
#include "net/tmwa/guildmanager.h"
#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "net/tmwa/sprite.h"

#include "resources/iteminfo.h"

#include "resources/db/itemdb.h"

#include "utils/stringutils.h"
#include "utils/timer.h"

#include "debug.h"

extern Net::BeingHandler *beingHandler;
extern int serverVersion;

namespace TmwAthena
{

BeingHandler::BeingHandler(const bool enableSync) :
    MessageHandler(),
    Ea::BeingHandler(enableSync)
{
    static const uint16_t _messages[] =
    {
        SMSG_BEING_VISIBLE,
        SMSG_BEING_MOVE,
        SMSG_BEING_MOVE2,
        SMSG_BEING_REMOVE,
        SMSG_SKILL_DAMAGE,
        SMSG_BEING_ACTION,
        SMSG_BEING_SELFEFFECT,
        SMSG_BEING_EMOTION,
        SMSG_BEING_CHANGE_LOOKS,
        SMSG_BEING_CHANGE_LOOKS2,
        SMSG_BEING_NAME_RESPONSE,
        SMSG_PLAYER_GUILD_PARTY_INFO,
        SMSG_BEING_CHANGE_DIRECTION,
        SMSG_PLAYER_UPDATE_1,
        SMSG_PLAYER_UPDATE_2,
        SMSG_PLAYER_MOVE,
        SMSG_PLAYER_STOP,
        SMSG_PLAYER_MOVE_TO_ATTACK,
        SMSG_PLAYER_STATUS_CHANGE,
        SMSG_BEING_STATUS_CHANGE,
        SMSG_BEING_RESURRECT,
        SMSG_SOLVE_CHAR_NAME,
        SMSG_BEING_SPAWN,
        SMSG_SKILL_CASTING,
        SMSG_SKILL_CAST_CANCEL,
        SMSG_SKILL_NO_DAMAGE,
        SMSG_BEING_IP_RESPONSE,
        SMSG_PVP_MAP_MODE,
        SMSG_PVP_SET,
        SMSG_BEING_MOVE3,
        0
    };
    handledMessages = _messages;
    beingHandler = this;
}

void BeingHandler::requestNameById(const BeingId id) const
{
    createOutPacket(CMSG_NAME_REQUEST);
    outMsg.writeBeingId(id, "being id");
}

void BeingHandler::handleMessage(Net::MessageIn &msg)
{
    BLOCK_START("BeingHandler::handleMessage")
    switch (msg.getId())
    {
        case SMSG_BEING_VISIBLE:
            BeingNet::processBeingVisible(msg);
            break;

        case SMSG_BEING_MOVE:
            BeingNet::processBeingMove(msg);
            break;

        case SMSG_BEING_MOVE2:
            BeingNet::processBeingMove2(msg);
            break;

        case SMSG_BEING_MOVE3:
            Ea::BeingNet::processBeingMove3(msg);
            break;

        case SMSG_BEING_SPAWN:
            BeingNet::processBeingSpawn(msg);
            break;

        case SMSG_BEING_REMOVE:
            Ea::BeingNet::processBeingRemove(msg);
            break;

        case SMSG_BEING_RESURRECT:
            BeingNet::processBeingResurrect(msg);
            break;

        case SMSG_SKILL_DAMAGE:
            Ea::BeingNet::processSkillDamage(msg);
            break;

        case SMSG_BEING_ACTION:
            Ea::BeingNet::processBeingAction(msg);
            break;

        case SMSG_BEING_SELFEFFECT:
            BeingNet::processBeingSelfEffect(msg);
            break;

        case SMSG_BEING_EMOTION:
            Ea::BeingNet::processBeingEmotion(msg);
            break;

        case SMSG_BEING_CHANGE_LOOKS:
            BeingNet::processBeingChangeLook(msg);
            break;

        case SMSG_BEING_CHANGE_LOOKS2:
            BeingNet::processBeingChangeLook2(msg);
            break;

        case SMSG_BEING_NAME_RESPONSE:
            Ea::BeingNet::processNameResponse(msg);
            break;

        case SMSG_BEING_IP_RESPONSE:
            BeingNet::processIpResponse(msg);
            break;

        case SMSG_SOLVE_CHAR_NAME:
            break;

        case SMSG_PLAYER_GUILD_PARTY_INFO:
            BeingNet::processPlayerGuilPartyInfo(msg);
            break;

        case SMSG_BEING_CHANGE_DIRECTION:
            BeingNet::processBeingChangeDirection(msg);
            break;

        case SMSG_PLAYER_UPDATE_1:
            BeingNet::processPlayerUpdate1(msg);
            break;

        case SMSG_PLAYER_UPDATE_2:
            BeingNet::processPlayerUpdate2(msg);
            break;

        case SMSG_PLAYER_MOVE:
            BeingNet::processPlayerMove(msg);
            break;

        case SMSG_PLAYER_STOP:
            Ea::BeingNet::processPlayerStop(msg);
            break;

        case SMSG_PLAYER_MOVE_TO_ATTACK:
            Ea::BeingNet::processPlayerMoveToAttack(msg);
            break;

        case SMSG_PLAYER_STATUS_CHANGE:
            BeingNet::processPlaterStatusChange(msg);
            break;

        case SMSG_BEING_STATUS_CHANGE:
            BeingNet::processBeingStatusChange(msg);
            break;

        case SMSG_SKILL_CASTING:
            BeingNet::processSkillCasting(msg);
            break;

        case SMSG_SKILL_CAST_CANCEL:
            BeingNet::processSkillCastCancel(msg);
            break;

        case SMSG_SKILL_NO_DAMAGE:
            Ea::BeingNet::processSkillNoDamage(msg);
            break;

        case SMSG_PVP_MAP_MODE:
            Ea::BeingNet::processPvpMapMode(msg);
            break;

        case SMSG_PVP_SET:
            BeingNet::processPvpSet(msg);
            break;

        default:
            break;
    }
    BLOCK_END("BeingHandler::handleMessage")
}

void BeingHandler::undress(Being *const being) const
{
    if (!being)
        return;
    being->setSprite(SPRITE_WEAPON, 0);
    being->setSprite(SPRITE_HEAD_BOTTOM, 0);
    being->setSprite(SPRITE_CLOTHES_COLOR, 0);
    being->setSprite(SPRITE_HAIR, 0);
    being->setSprite(SPRITE_SHOES, 0);
//    being->setSprite(SPRITE_BODY, 0, "", true);
}

#ifdef EATHENA_SUPPORT
void BeingHandler::requestRanks(const RankT rank A_UNUSED) const
{
}
#endif

void BeingHandler::viewPlayerEquipment(const Being *const being A_UNUSED)
{
}

}  // namespace TmwAthena