Skip to content

Commit 47929e2

Browse files
committed
Fixed funny business with empty fighter weapon slots.
1 parent bb3b434 commit 47929e2

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

‎src/Geoscape/DogfightState.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,11 +1333,11 @@ void DogfightState::btnCautiousClick(Action *)
13331333
{
13341334
_end = false;
13351335
setStatus("STR_CAUTIOUS_ATTACK");
1336-
if (_craft->getNumWeapons() > 0 && _craft->getWeapons()->at(0) != 0)
1336+
if (_craft->getRules()->getWeapons() > 0 && _craft->getWeapons()->at(0) != 0)
13371337
{
13381338
_w1Timer->setInterval(_craft->getWeapons()->at(0)->getRules()->getCautiousReload() * _timeScale);
13391339
}
1340-
if (_craft->getNumWeapons() > 1 && _craft->getWeapons()->at(1) != 0)
1340+
if (_craft->getRules()->getWeapons() > 1 && _craft->getWeapons()->at(1) != 0)
13411341
{
13421342
_w2Timer->setInterval(_craft->getWeapons()->at(1)->getRules()->getCautiousReload() * _timeScale);
13431343
}
@@ -1356,11 +1356,11 @@ void DogfightState::btnStandardClick(Action *)
13561356
{
13571357
_end = false;
13581358
setStatus("STR_STANDARD_ATTACK");
1359-
if (_craft->getNumWeapons() > 0 && _craft->getWeapons()->at(0) != 0)
1359+
if (_craft->getRules()->getWeapons() > 0 && _craft->getWeapons()->at(0) != 0)
13601360
{
13611361
_w1Timer->setInterval(_craft->getWeapons()->at(0)->getRules()->getStandardReload() * _timeScale);
13621362
}
1363-
if (_craft->getNumWeapons() > 1 && _craft->getWeapons()->at(1) != 0)
1363+
if (_craft->getRules()->getWeapons() > 1 && _craft->getWeapons()->at(1) != 0)
13641364
{
13651365
_w2Timer->setInterval(_craft->getWeapons()->at(1)->getRules()->getStandardReload() * _timeScale);
13661366
}
@@ -1379,11 +1379,11 @@ void DogfightState::btnAggressiveClick(Action *)
13791379
{
13801380
_end = false;
13811381
setStatus("STR_AGGRESSIVE_ATTACK");
1382-
if (_craft->getNumWeapons() > 0 && _craft->getWeapons()->at(0) != 0)
1382+
if (_craft->getRules()->getWeapons() > 0 && _craft->getWeapons()->at(0) != 0)
13831383
{
13841384
_w1Timer->setInterval(_craft->getWeapons()->at(0)->getRules()->getAggressiveReload() * _timeScale);
13851385
}
1386-
if (_craft->getNumWeapons() > 1 && _craft->getWeapons()->at(1) != 0)
1386+
if (_craft->getRules()->getWeapons() > 1 && _craft->getWeapons()->at(1) != 0)
13871387
{
13881388
_w2Timer->setInterval(_craft->getWeapons()->at(1)->getRules()->getAggressiveReload() * _timeScale);
13891389
}

‎src/Savegame/Craft.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,13 @@ void Craft::load(const YAML::Node &node, const Ruleset *rule, SavedGame *save)
150150
{
151151
CraftWeapon *w = new CraftWeapon(rule->getCraftWeapon(type), 0);
152152
w->load(*i);
153-
_weapons[j++] = w;
153+
_weapons[j] = w;
154154
}
155+
else
156+
{
157+
_weapons[j] = 0;
158+
}
159+
j++;
155160
}
156161

157162
_items->load(node["items"]);

0 commit comments

Comments
 (0)