Skip to content

Commit cb9c04e

Browse files
committed
Base Functions
- function to return the total amount of alien containment at a given base - method in the debriefing screen for sending live aliens to storage, or displaying the "no containment" state if none found. - extra condition to exclude live aliens from the sell screen. - checks for containment at destination when transferring live aliens.
1 parent 85cb52c commit cb9c04e

7 files changed

Lines changed: 54 additions & 5 deletions

File tree

‎src/Basescape/SellState.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ SellState::SellState(Game *game, Base *base) : State(game), _base(base), _qtys()
167167
for (std::vector<std::string>::iterator i = items.begin(); i != items.end(); ++i)
168168
{
169169
int qty = _base->getItems()->getItem(*i);
170-
if (qty > 0)
170+
if (qty > 0 && !_game->getRuleset()->getItem(*i)->getAlien())
171171
{
172172
_qtys.push_back(0);
173173
_items.push_back(*i);

‎src/Basescape/TransferItemsState.cpp‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace OpenXcom
5252
* @param baseFrom Pointer to the source base.
5353
* @param baseTo Pointer to the destination base.
5454
*/
55-
TransferItemsState::TransferItemsState(Game *game, Base *baseFrom, Base *baseTo) : State(game), _baseFrom(baseFrom), _baseTo(baseTo), _qtys(), _soldiers(), _crafts(), _items(), _sel(0), _total(0), _sOffset(0), _eOffset(0), _pQty(0), _cQty(0), _iQty(0.0f), _distance(0.0)
55+
TransferItemsState::TransferItemsState(Game *game, Base *baseFrom, Base *baseTo) : State(game), _baseFrom(baseFrom), _baseTo(baseTo), _qtys(), _soldiers(), _crafts(), _items(), _sel(0), _total(0), _sOffset(0), _eOffset(0), _pQty(0), _cQty(0), _iQty(0.0f), _distance(0.0), _aOffset(0)
5656
{
5757
// Create objects
5858
_window = new Window(this, 320, 200, 0, 0);
@@ -163,6 +163,10 @@ TransferItemsState::TransferItemsState(Game *game, Base *baseFrom, Base *baseTo)
163163
int qty = _baseFrom->getItems()->getItem(*i);
164164
if (qty > 0)
165165
{
166+
if(!_game->getRuleset()->getItem(*i)->getAlien())
167+
{
168+
_aOffset++;
169+
}
166170
_qtys.push_back(0);
167171
_items.push_back(*i);
168172
std::wstringstream ss, ss2;
@@ -523,8 +527,16 @@ void TransferItemsState::increase()
523527
_game->pushState(new ErrorMessageState(_game, "STR_NO_FREE_ACCOMODATION_CREW", Palette::blockOffset(15)+1, "BACK13.SCR", 0));
524528
return;
525529
}
530+
if (_sel >= _soldiers.size() + _crafts.size() + _sOffset + _eOffset + _aOffset &&
531+
_iQty + _game->getRuleset()->getItem(_items[_sel - _soldiers.size() - _crafts.size() - _sOffset - _eOffset - _aOffset])->getSize() > _baseTo->getAvailableContainment())
532+
{
533+
_timerInc->stop();
534+
_game->pushState(new ErrorMessageState(_game, "STR_NO_ALIEN_CONTAINMENT_FOR_TRANSFER", Palette::blockOffset(15)+1, "BACK13.SCR", 0));
535+
return;
536+
}
526537
}
527-
if (_sel >= _soldiers.size() + _crafts.size() + _sOffset + _eOffset && _iQty + _game->getRuleset()->getItem(_items[_sel - _soldiers.size() - _crafts.size() - _sOffset - _eOffset])->getSize() > _baseTo->getAvailableStores() - _baseTo->getUsedStores())
538+
if (_sel >= _soldiers.size() + _crafts.size() + _sOffset + _eOffset && _sel < _soldiers.size() + _crafts.size() + _sOffset + _eOffset + _aOffset &&
539+
_iQty + _game->getRuleset()->getItem(_items[_sel - _soldiers.size() - _crafts.size() - _sOffset - _eOffset])->getSize() > _baseTo->getAvailableStores() - _baseTo->getUsedStores())
528540
{
529541
_timerInc->stop();
530542
_game->pushState(new ErrorMessageState(_game, "STR_NOT_ENOUGH_STORE_SPACE", Palette::blockOffset(15)+1, "BACK13.SCR", 0));

‎src/Basescape/TransferItemsState.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class TransferItemsState : public State
5252
std::vector<Craft*> _crafts;
5353
std::vector<std::string> _items;
5454
unsigned int _sel;
55-
int _total, _sOffset, _eOffset, _pQty, _cQty;
55+
int _total, _sOffset, _eOffset, _pQty, _cQty, _aOffset;
5656
float _iQty;
5757
double _distance;
5858
Timer *_timerInc, *_timerDec;

‎src/Battlescape/DebriefingState.cpp‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "../Savegame/TerrorSite.h"
4343
#include "PromotionsState.h"
4444
#include "CannotReequipState.h"
45+
#include "NoContainmentState.h"
4546

4647
namespace OpenXcom
4748
{
@@ -50,7 +51,7 @@ namespace OpenXcom
5051
* Initializes all the elements in the Debriefing screen.
5152
* @param game Pointer to the core game.
5253
*/
53-
DebriefingState::DebriefingState(Game *game) : State(game)
54+
DebriefingState::DebriefingState(Game *game) : State(game), _noContainment(false)
5455
{
5556
// Create objects
5657
_window = new Window(this, 320, 200, 0, 0);
@@ -214,6 +215,10 @@ void DebriefingState::btnOkClick(Action *action)
214215
{
215216
_game->pushState(new CannotReequipState(_game, _missingItems));
216217
}
218+
if (_noContainment)
219+
{
220+
_game->pushState (new NoContainmentState(_game));
221+
}
217222
}
218223

219224

@@ -384,6 +389,16 @@ void DebriefingState::prepareDebriefing()
384389
if (faction == FACTION_HOSTILE && (!aborted || (*j)->isInExitArea()))
385390
{
386391
addStat("STR_LIVE_ALIENS_RECOVERED", 1, value*2);
392+
if(base->getAvailableContainment())
393+
{
394+
std::stringstream ss;
395+
ss << "STR_" << (*j)->getType();
396+
base->getItems()->addItem(ss.str(), 1);
397+
}
398+
else
399+
{
400+
_noContainment = true;
401+
}
387402
}
388403
}
389404
else

‎src/Battlescape/DebriefingState.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class DebriefingState : public State
5555
void prepareDebriefing();
5656
void recoverItems(std::vector<BattleItem*> *from, Base *base);
5757
void reequipCraft(Base *base, Craft *craft);
58+
bool _noContainment;
5859
public:
5960
/// Creates the Debriefing state.
6061
DebriefingState(Game *game);

‎src/Savegame/Base.cpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,4 +943,23 @@ bool Base::getHyperDetection() const
943943
}
944944
return false;
945945
}
946+
947+
/**
948+
* Returns the total amount of Containment Space
949+
* available in the base.
950+
* @return Containment Lab space.
951+
*/
952+
int Base::getAvailableContainment() const
953+
{
954+
int total = 0;
955+
for (std::vector<BaseFacility*>::const_iterator i = _facilities.begin(); i != _facilities.end(); ++i)
956+
{
957+
if ((*i)->getBuildTime() == 0)
958+
{
959+
total += (*i)->getRules()->getAliens();
960+
}
961+
}
962+
return total;
963+
}
964+
946965
}

‎src/Savegame/Base.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ class Base : public Target
163163
const std::vector<Production *> & getProductions () const;
164164
/// Checks if this base is hyper-wave equipped.
165165
bool getHyperDetection() const;
166+
/// Gets the total amount of Containment Space
167+
int getAvailableContainment() const;
166168
};
167169

168170
}

0 commit comments

Comments
 (0)