ManaPlus
maprecv.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2008 Lloyd Bryant <[email protected]>
4  * Copyright (C) 2011-2018 The ManaPlus Developers
5  *
6  * This file is part of The ManaPlus 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 
22 #include "net/ea/maprecv.h"
23 
24 #include "gui/viewport.h"
25 
26 #include "resources/map/map.h"
27 
28 #include "net/messagein.h"
29 
30 #include "debug.h"
31 
32 namespace Ea
33 {
34 
36 {
37  const int x1 = msg.readInt16("x1");
38  const int y1 = msg.readInt16("y1");
39  const int x2 = msg.readInt16("x2");
40  const int y2 = msg.readInt16("y2");
41  const BlockTypeT mask = static_cast<BlockTypeT>(msg.readInt32("mask"));
42  const int layer = msg.readInt32("layer");
43  const std::string name = msg.readString(16, "map name");
44  if (layer != 0)
45  return;
46  Map *const map = viewport->getMap();
47  if ((map != nullptr) && map->getGatName() == name)
48  {
49  for (int y = y1; y <= y2; y ++)
50  {
51  for (int x = x1; x <= x2; x ++)
52  map->setBlockMask(x, y, mask);
53  }
54  map->updateConditionLayers();
55  map->preCacheLayers();
56  }
57 }
58 
59 } // namespace Ea
const std::string getGatName() const
Definition: map.cpp:850
void updateConditionLayers()
Definition: map.cpp:1728
BlockType ::T BlockTypeT
Definition: blocktype.h:40
bool msg(InputEvent &event)
Definition: chat.cpp:38
void setBlockMask(const int x, const int y, const BlockTypeT type)
Definition: map.cpp:741
void processSetTilesType(Net::MessageIn &msg)
Definition: maprecv.cpp:35
int16_t readInt16(const char *const str)
Definition: messagein.cpp:130
void preCacheLayers()
Definition: map.cpp:1742
Definition: map.h:71
std::string readString(int length, const char *const dstr)
Definition: messagein.cpp:367
Map * getMap() const
Definition: viewport.h:134
int32_t readInt32(const char *const str)
Definition: messagein.cpp:174
Viewport * viewport
Definition: viewport.cpp:35