GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/ea/maprecv.cpp Lines: 1 18 5.6 %
Date: 2017-11-29 Branches: 0 20 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2008  Lloyd Bryant <[email protected]>
4
 *  Copyright (C) 2011-2017  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
35
void MapRecv::processSetTilesType(Net::MessageIn &msg)
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
4
}  // namespace Ea