Mana
Loading...
Searching...
No Matches
itemhandler.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
23
24#include "net/tmwa/messagein.h"
25#include "net/tmwa/protocol.h"
26
27#include "actorspritemanager.h"
28#include "game.h"
29#include "map.h"
30
31namespace TmwAthena {
32
34{
35 static const uint16_t _messages[] = {
39 0
40 };
41 handledMessages = _messages;
42}
43
45{
46 switch (msg.getId())
47 {
50 {
51 int id = msg.readInt32();
52 int itemId = msg.readInt16();
53 msg.readInt8(); // identify flag
54 int x = msg.readInt16();
55 int y = msg.readInt16();
56 msg.skip(4); // amount,subX,subY / subX,subY,amount
57
58 Game *game = Game::instance();
59 if (!game)
60 break;
61
62 if (Map *map = game->getCurrentMap())
64 map->getTileCenter(x, y));
65 }
66 break;
67
71 break;
72 }
73}
74
75} // namespace TmwAthena
ActorSpriteManager * actorSpriteManager
Definition game.cpp:110
FloorItem * findItem(int id) const
Returns a specific FloorItem, by id.
void destroyActor(ActorSprite *actor)
Immediately destroys the given actor.
FloorItem * createItem(int id, int itemId, const Vector &position)
Create a FloorItem and add it to the list of ActorSprites.
An item lying on the floor.
Definition flooritem.h:32
The main class responsible for running the game.
Definition game.h:37
Map * getCurrentMap()
Returns the currently active map.
Definition game.h:70
static Game * instance()
Provides access to the game instance.
Definition game.h:53
A tile map.
Definition map.h:147
const uint16_t * handledMessages
void handleMessage(MessageIn &msg) override
Used for parsing an incoming message from eAthena.
Definition messagein.h:35
void skip(unsigned int length)
Skips a given number of bytes.
uint16_t readInt16()
Reads an unsigned 16-bit integer from the message.
Definition messagein.cpp:57
uint8_t readInt8()
Reads an unsigned 8-bit integer from the message.
Definition messagein.cpp:46
uint16_t getId() const
Returns the message ID.
Definition messagein.h:42
uint32_t readInt32()
Reads an unsigned 32-bit integer from the message.
Definition messagein.cpp:69
Warning: buffers and other variables are shared, so there can be only one connection active at a time...
@ SMSG_ITEM_REMOVE
Definition protocol.h:191
@ SMSG_ITEM_DROPPED
Definition protocol.h:188
@ SMSG_ITEM_VISIBLE
Definition protocol.h:187