Skip to content

Commit 02dda78

Browse files
committed
Merge remote-tracking branch 'upstream/master' into dual_boot
2 parents 527127b + 28bdaf9 commit 02dda78

8 files changed

Lines changed: 78 additions & 5 deletions

File tree

src/Geoscape/GeoscapeState.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,13 @@ void GeoscapeState::time5Seconds()
822822
}
823823
if ((*j)->reachedDestination())
824824
{
825+
if ((*j)->getDestination()->getSiteDepth() > (*j)->getRules()->getMaxDepth())
826+
{
827+
std::wstring msg = tr("STR_SITE_TOO_DEEP").arg((*j)->getName(_game->getLanguage()));
828+
(*j)->returnToBase();
829+
popup(new CraftErrorState(this, msg));
830+
continue;
831+
}
825832
Ufo* u = dynamic_cast<Ufo*>((*j)->getDestination());
826833
Waypoint *w = dynamic_cast<Waypoint*>((*j)->getDestination());
827834
MissionSite* m = dynamic_cast<MissionSite*>((*j)->getDestination());

src/Ruleset/AlienDeployment.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace OpenXcom
108108
* type of deployment data.
109109
* @param type String defining the type.
110110
*/
111-
AlienDeployment::AlienDeployment(const std::string &type) : _type(type), _width(0), _length(0), _height(0), _civilians(0), _shade(-1), _noRetreat(false), _finalDestination(false), _finalMission(false), _markerIcon(-1), _durationMin(0), _durationMax(0), _minDepth(0), _maxDepth(0)
111+
AlienDeployment::AlienDeployment(const std::string &type) : _type(type), _width(0), _length(0), _height(0), _civilians(0), _shade(-1), _noRetreat(false), _finalDestination(false), _finalMission(false), _markerIcon(-1), _durationMin(0), _durationMax(0), _minDepth(0), _maxDepth(0), _minSiteDepth(0), _maxSiteDepth(0)
112112
{
113113
}
114114

@@ -148,6 +148,11 @@ void AlienDeployment::load(const YAML::Node &node)
148148
_minDepth = node["depth"][0].as<int>(_minDepth);
149149
_maxDepth = node["depth"][1].as<int>(_maxDepth);
150150
}
151+
if (node["siteDepth"])
152+
{
153+
_minSiteDepth = node["siteDepth"][0].as<int>(_minSiteDepth);
154+
_maxSiteDepth = node["siteDepth"][1].as<int>(_maxSiteDepth);
155+
}
151156
if (node["duration"])
152157
{
153158
_durationMin = node["duration"][0].as<int>(_durationMin);
@@ -353,4 +358,22 @@ int AlienDeployment::getMaxDepth()
353358
return _maxDepth;
354359
}
355360

361+
/**
362+
* Gets The minimum depth for this deployment's mission site.
363+
* @return The minimum depth.
364+
*/
365+
int AlienDeployment::getMinSiteDepth()
366+
{
367+
return _minSiteDepth;
368+
}
369+
370+
/**
371+
* Gets The maximum depth for this deployment's mission site.
372+
* @return The maximum depth.
373+
*/
374+
int AlienDeployment::getMaxSiteDepth()
375+
{
376+
return _maxSiteDepth;
377+
}
378+
356379
}

src/Ruleset/AlienDeployment.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class AlienDeployment
7171
std::string _alert;
7272
BriefingData _briefingData;
7373
std::string _markerName;
74-
int _markerIcon, _durationMin, _durationMax, _minDepth, _maxDepth;
74+
int _markerIcon, _durationMin, _durationMax, _minDepth, _maxDepth, _minSiteDepth, _maxSiteDepth;
7575
public:
7676
/// Creates a blank Alien Deployment ruleset.
7777
AlienDeployment(const std::string &type);
@@ -121,6 +121,10 @@ class AlienDeployment
121121
int getMinDepth();
122122
/// Gets the maximum depth.
123123
int getMaxDepth();
124+
/// Gets the minimum site depth.
125+
int getMinSiteDepth();
126+
/// Gets the maximum site depth.
127+
int getMaxSiteDepth();
124128
};
125129

126130
}

src/Ruleset/RuleCraft.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace OpenXcom
2727
* type of craft.
2828
* @param type String defining the type.
2929
*/
30-
RuleCraft::RuleCraft(const std::string &type) : _type(type), _sprite(-1), _marker(-1), _fuelMax(0), _damageMax(0), _speedMax(0), _accel(0), _weapons(0), _soldiers(0), _vehicles(0), _costBuy(0), _costRent(0), _costSell(0), _repairRate(1), _refuelRate(1), _radarRange(672), _sightRange(1696), _transferTime(0), _score(0), _battlescapeTerrainData(0), _spacecraft(false), _listOrder(0), _maxItems(0)
30+
RuleCraft::RuleCraft(const std::string &type) : _type(type), _sprite(-1), _marker(-1), _fuelMax(0), _damageMax(0), _speedMax(0), _accel(0), _weapons(0), _soldiers(0), _vehicles(0), _costBuy(0), _costRent(0), _costSell(0), _repairRate(1), _refuelRate(1), _radarRange(672), _sightRange(1696), _transferTime(0), _score(0), _battlescapeTerrainData(0), _spacecraft(false), _listOrder(0), _maxItems(0), _maxDepth(0)
3131
{
3232

3333
}
@@ -93,6 +93,7 @@ void RuleCraft::load(const YAML::Node &node, Ruleset *ruleset, int modIndex, int
9393
{
9494
_listOrder = listOrder;
9595
}
96+
_maxDepth = node["maxDepth"].as<int>(_maxDepth);
9697
_maxItems = node["maxItems"].as<int>(_maxItems);
9798
}
9899

@@ -348,5 +349,15 @@ int RuleCraft::getMaxItems() const
348349
return _maxItems;
349350
}
350351

352+
/**
353+
* Gets the maximum depth this craft can dive to.
354+
* @return max depth.
355+
*/
356+
int RuleCraft::getMaxDepth() const
357+
{
358+
return _maxDepth;
359+
}
360+
361+
351362
}
352363

src/Ruleset/RuleCraft.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class RuleCraft
4646
int _repairRate, _refuelRate, _radarRange, _sightRange, _transferTime, _score;
4747
RuleTerrain *_battlescapeTerrainData;
4848
bool _spacecraft;
49-
int _listOrder, _maxItems;
49+
int _listOrder, _maxItems, _maxDepth;
5050
std::vector<std::vector <int> > _deployment;
5151
public:
5252
/// Creates a blank craft ruleset.
@@ -107,6 +107,8 @@ class RuleCraft
107107
std::vector<std::vector<int> > &getDeployment();
108108
/// Gets the item limit for this craft.
109109
int getMaxItems() const;
110+
/// checks how deep this craft can go.
111+
int getMaxDepth() const;
110112
};
111113

112114
}

src/Savegame/AlienMission.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ MissionSite *AlienMission::spawnMissionSite(SavedGame &game, const Ruleset &rule
703703
missionSite->setAlienRace(_race);
704704
missionSite->setTexture(area.texture);
705705
missionSite->setCity(area.name);
706+
missionSite->setSiteDepth(RNG::generate(deployment->getMinSiteDepth(), deployment->getMaxSiteDepth()));
706707
return missionSite;
707708
}
708709
return 0;

src/Savegame/Target.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace OpenXcom
2929
/**
3030
* Initializes a target with blank coordinates.
3131
*/
32-
Target::Target() : _lon(0.0), _lat(0.0)
32+
Target::Target() : _lon(0.0), _lat(0.0), _depth(0)
3333
{
3434
}
3535

@@ -56,6 +56,7 @@ void Target::load(const YAML::Node &node)
5656
{
5757
_lon = node["lon"].as<double>(_lon);
5858
_lat = node["lat"].as<double>(_lat);
59+
_depth = node["depth"].as<int>(_depth);
5960
}
6061

6162
/**
@@ -67,6 +68,8 @@ YAML::Node Target::save() const
6768
YAML::Node node;
6869
node["lon"] = serializeDouble(_lon);
6970
node["lat"] = serializeDouble(_lat);
71+
if (_depth)
72+
node["depth"] = _depth;
7073
return node;
7174
}
7275

@@ -156,4 +159,21 @@ double Target::getDistance(const Target *target) const
156159
return acos(cos(_lat) * cos(target->getLatitude()) * cos(target->getLongitude() - _lon) + sin(_lat) * sin(target->getLatitude()));
157160
}
158161

162+
/**
163+
* Gets the mission site's depth.
164+
* @return the depth of the site.
165+
*/
166+
int Target::getSiteDepth()
167+
{
168+
return _depth;
169+
}
170+
171+
/**
172+
* Sets the mission site's depth.
173+
* @param depth the depth we want.
174+
*/
175+
void Target::setSiteDepth(int depth)
176+
{
177+
_depth = depth;
178+
}
159179
}

src/Savegame/Target.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Target
3636
{
3737
protected:
3838
double _lon, _lat;
39+
int _depth;
3940
std::vector<Target*> _followers;
4041
/// Creates a target.
4142
Target();
@@ -64,6 +65,10 @@ class Target
6465
std::vector<Target*> *getFollowers();
6566
/// Gets the distance to another target.
6667
double getDistance(const Target *target) const;
68+
/// Gets the depth of the target.
69+
int getSiteDepth();
70+
/// Sets the depth of the target.
71+
void setSiteDepth(int depth);
6772
};
6873

6974
}

0 commit comments

Comments
 (0)