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-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "net/ea/maprecv.h"
24 
25 #include "gui/viewport.h"
26 
27 #include "resources/map/map.h"
28 
29 #include "net/messagein.h"
30 
31 #include "debug.h"
32 
33 namespace Ea
34 {
35 
37 {
38  const int x1 = msg.readInt16("x1");
39  const int y1 = msg.readInt16("y1");
40  const int x2 = msg.readInt16("x2");
41  const int y2 = msg.readInt16("y2");
42  const BlockTypeT mask = static_cast<BlockTypeT>(msg.readInt32("mask"));
43  const int layer = msg.readInt32("layer");
44  const std::string name = msg.readString(16, "map name");
45  if (layer != 0)
46  return;
47  Map *const map = viewport->getMap();
48  if ((map != nullptr) && map->getGatName() == name)
49  {
50  for (int y = y1; y <= y2; y ++)
51  {
52  for (int x = x1; x <= x2; x ++)
53  map->setBlockMask(x, y, mask);
54  }
55  map->updateConditionLayers();
56  map->preCacheLayers();
57  }
58 }
59 
60 } // namespace Ea
BlockType ::T BlockTypeT
Definition: blocktype.h:41
Definition: map.h:75
void preCacheLayers()
Definition: map.cpp:1746
void setBlockMask(const int x, const int y, const BlockTypeT type)
Definition: map.cpp:746
void updateConditionLayers()
Definition: map.cpp:1732
const std::string getGatName() const
Definition: map.cpp:855
Map * getMap() const
Definition: viewport.h:135
Viewport * viewport
Definition: viewport.cpp:36
bool msg(InputEvent &event)
Definition: chat.cpp:39
void processSetTilesType(Net::MessageIn &msg)
Definition: maprecv.cpp:36