Repository navigation
Expand file tree
/
Copy pathMCDPatch.cpp
More file actions
141 lines (134 loc) · 3.8 KB
/
Copy pathMCDPatch.cpp
File metadata and controls
141 lines (134 loc) · 3.8 KB
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
/*
* Copyright 2010-2013 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom 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 3 of the License, or
* (at your option) any later version.
*
* OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MCDPatch.h"
#include "Ruleset.h"
#include "MapDataSet.h"
#include "MapData.h"
#include "../Engine/CrossPlatform.h"
#include <sstream>
namespace OpenXcom
{
/**
* Initializes an MCD Patch
*/
MCDPatch::MCDPatch()
{
}
/**
*
*/
MCDPatch::~MCDPatch()
{
}
/**
* Loads the MCD Patch from a YAML file.
* TODO: fill this out with more data.
* @param node YAML node.
*/
void MCDPatch::load(const YAML::Node &node)
{
for (YAML::Iterator i = node.begin(); i != node.end(); ++i)
{
std::string key;
i.first() >> key;
if (key == "data")
{
for (YAML::Iterator j = i.second().begin(); j != i.second().end(); ++j)
{
size_t MCDIndex;
(*j)["MCDIndex"] >> MCDIndex;
if (const YAML::Node *pName = (*j).FindValue("bigWall"))
{
int bigWall;
(*pName) >> bigWall;
_bigWalls.push_back(std::make_pair(MCDIndex, bigWall));
}
if (const YAML::Node *pName = (*j).FindValue("TUWalk"))
{
int TUWalk;
(*pName) >> TUWalk;
_TUWalks.push_back(std::make_pair(MCDIndex, TUWalk));
}
if (const YAML::Node *pName = (*j).FindValue("TUFly"))
{
int TUFly;
(*pName) >> TUFly;
_TUFlys.push_back(std::make_pair(MCDIndex, TUFly));
}
if (const YAML::Node *pName = (*j).FindValue("TUSlide"))
{
int TUSlide;
(*pName) >> TUSlide;
_TUSlides.push_back(std::make_pair(MCDIndex, TUSlide));
}
if (const YAML::Node *pName = (*j).FindValue("deathTile"))
{
int deathTile;
(*pName) >> deathTile;
_deathTiles.push_back(std::make_pair(MCDIndex, deathTile));
}
if (const YAML::Node *pName = (*j).FindValue("terrainHeight"))
{
int terrainHeight;
(*pName) >> terrainHeight;
_terrainHeight.push_back(std::make_pair(MCDIndex, terrainHeight));
}
}
}
}
}
/**
* Saves the MCD Patch to a YAML file.
* @param out YAML emitter.
*/
void MCDPatch::save(YAML::Emitter &out UNUSED_PARAM) const
{
}
/**
* Applies an MCD patch to a mapDataSet.
* @param dataSet the MapDataSet we want to modify.
*/
void MCDPatch::modifyData(MapDataSet *dataSet) const
{
for (std::vector<std::pair<size_t, int> >::const_iterator i = _bigWalls.begin(); i != _bigWalls.end(); ++i)
{
dataSet->getObjects()->at(i->first)->setBigWall(i->second);
}
for (std::vector<std::pair<size_t, int> >::const_iterator i = _TUWalks.begin(); i != _TUWalks.end(); ++i)
{
dataSet->getObjects()->at(i->first)->setTUWalk(i->second);
}
for (std::vector<std::pair<size_t, int> >::const_iterator i = _TUFlys.begin(); i != _TUFlys.end(); ++i)
{
dataSet->getObjects()->at(i->first)->setTUFly(i->second);
}
for (std::vector<std::pair<size_t, int> >::const_iterator i = _TUSlides.begin(); i != _TUSlides.end(); ++i)
{
dataSet->getObjects()->at(i->first)->setTUSlide(i->second);
}
for (std::vector<std::pair<size_t, int> >::const_iterator i = _deathTiles.begin(); i != _deathTiles.end(); ++i)
{
dataSet->getObjects()->at(i->first)->setDieMCD(i->second);
}
for (std::vector<std::pair<size_t, int> >::const_iterator i = _terrainHeight.begin(); i != _terrainHeight.end(); ++i)
{
dataSet->getObjects()->at(i->first)->setTerrainLevel(i->second);
}
}
}