While hammering away on my Geoscape AI project I got sick of being bitten in the ass with the 8-base limitation.
The AI in the current form just doesn't forgive any interception, and if the base responsible was in detection range of faction being intercepted, and if they have particularly bitter hangover at the moment (which they usually do), and they have enough forces at the ready, there goes your base. So bases became that much more disposable. Just hope the crackdown is detected so you can cheat and transfer all the stuff away (to be fixed, so that you won't be able to do that in a couple of clicks :) ). Also I'm experimenting with reducing detection range in favor of scan frequency. This obviously raises number of bases needed.
Long story short, here's a minimal patch extending max number of bases to 16.
After you build 9th base, the 'NEW HIDEOUT' button is replaced by the second row of bases. To build more, click on an empty base slot.
The click works before that too.
(https://s3.postimg.org/xamwmzugz/image.png) (https://postimg.org/image/tr0yx6rr3/)12B (https://postimage.org/app.php)
I guess a ruleset setting is needed instead of hardcoded constants like 8 or 16.
I got lost in git right now, so here's the patch if anyone's interested:
diff --git a/src/Basescape/BasescapeState.cpp b/src/Basescape/BasescapeState.cpp
index 76738cd..3988e12 100644
--- a/src/Basescape/BasescapeState.cpp
+++ b/src/Basescape/BasescapeState.cpp
@@ -68,7 +68,13 @@ BasescapeState::BasescapeState(Base *base, Globe *globe) : _base(base), _globe(g
https:// Create objects
_txtFacility = new Text(192, 9, 0, 0);
_view = new BaseView(192, 192, 0, 8);
+ if ( _game->getSavedGame()->getBases()->size() > MiniBaseView::ROW_BASES) {
+ _mini = new MiniBaseView(128, 32, 192, 38);
+ }
+ else
+ {
_mini = new MiniBaseView(128, 16, 192, 41);
+ }
_edtBase = new TextEdit(this, 127, 17, 193, 0);
_txtLocation = new Text(126, 9, 194, 16);
_txtFunds = new Text(126, 9, 194, 24);
@@ -203,8 +209,7 @@ void BasescapeState::init()
}
_txtFunds->setText(tr("STR_FUNDS").arg(Text::formatFunding(_game->getSavedGame()->getFunds())));
-
- _btnNewBase->setVisible(_game->getSavedGame()->getBases()->size() < MiniBaseView::MAX_BASES);
+ _btnNewBase->setVisible(_game->getSavedGame()->getBases()->size() <= MiniBaseView::ROW_BASES);
}
/**
@@ -480,7 +485,7 @@ void BasescapeState::viewMouseOut(Action *)
* Selects a new base to display.
* @param action Pointer to an action.
*/
-void BasescapeState::miniLeftClick(Action *)
+void BasescapeState::miniLeftClick(Action *unused)
{
size_t base = _mini->getHoveredBase();
if (base < _game->getSavedGame()->getBases()->size())
@@ -488,13 +493,17 @@ void BasescapeState::miniLeftClick(Action *)
_base = _game->getSavedGame()->getBases()->at(base);
init();
}
+ else
+ {
+ btnNewBaseClick(unused);
+ }
}
/**
* Opens a dialog to make the selected base your HQ.
* @param action Pointer to an action.
*/
-void BasescapeState::miniRightClick(Action *)
+void BasescapeState::miniRightClick(Action *unused)
{
size_t baseIndex = _mini->getHoveredBase();
@@ -510,6 +519,10 @@ void BasescapeState::miniRightClick(Action *)
_game->pushState(new ChangeHeadquartersState(_game->getSavedGame()->getBases()->at(baseIndex)));
}
}
+ else
+ {
+ btnNewBaseClick(unused);
+ }
}
/**
diff --git a/src/Basescape/MiniBaseView.cpp b/src/Basescape/MiniBaseView.cpp
index 0ab1e4a..973197b 100644
--- a/src/Basescape/MiniBaseView.cpp
+++ b/src/Basescape/MiniBaseView.cpp
@@ -94,18 +94,20 @@ void MiniBaseView::draw()
Surface::draw();
for (size_t i = 0; i < MAX_BASES; ++i)
{
+ int cell_x = (i % ROW_BASES) * (MINI_SIZE + 2);
+ int cell_y = (i / ROW_BASES) * (MINI_SIZE + 2);
https:// Draw base squares
if (i == _base)
{
SDL_Rect r;
- r.x = i * (MINI_SIZE + 2);
- r.y = 0;
+ r.x = cell_x;
+ r.y = cell_y;
r.w = MINI_SIZE + 2;
r.h = MINI_SIZE + 2;
drawRect(&r, 1);
}
- _texture->getFrame(41)->setX(i * (MINI_SIZE + 2));
- _texture->getFrame(41)->setY(0);
+ _texture->getFrame(41)->setX(cell_x);
+ _texture->getFrame(41)->setY(cell_y);
_texture->getFrame(41)->blit(this);
https:// Draw facilities
@@ -121,8 +123,8 @@ void MiniBaseView::draw()
else
color = _red;
- r.x = i * (MINI_SIZE + 2) + 2 + (*f)->getX() * 2;
- r.y = 2 + (*f)->getY() * 2;
+ r.x = cell_x + 2 + (*f)->getX() * 2;
+ r.y = cell_y + 2 + (*f)->getY() * 2;
r.w = (*f)->getRules()->getSize() * 2;
r.h = (*f)->getRules()->getSize() * 2;
drawRect(&r, color+3);
@@ -156,6 +158,7 @@ void MiniBaseView::draw()
void MiniBaseView::mouseOver(Action *action, State *state)
{
_hoverBase = (int)floor(action->getRelativeXMouse() / ((MINI_SIZE + 2) * action->getXScale()));
+ _hoverBase += (int)floor(action->getRelativeYMouse() / ((MINI_SIZE + 2) * action->getYScale())) * ROW_BASES;
InteractiveSurface::mouseOver(action, state);
}
diff --git a/src/Basescape/MiniBaseView.h b/src/Basescape/MiniBaseView.h
index 9168634..0bef494 100644
--- a/src/Basescape/MiniBaseView.h
+++ b/src/Basescape/MiniBaseView.h
@@ -43,7 +43,8 @@ private:
size_t _base, _hoverBase;
Uint8 _red, _green;
public:
- static const size_t MAX_BASES = 8;
+ static const size_t MAX_BASES = 16;
+ static const size_t ROW_BASES = 8;
https:/// Creates a new mini base view at the specified position and size.
MiniBaseView(int width, int height, int x = 0, int y = 0);
https:/// Cleans up the mini base view.
EDIT: yea, it doesn't show extra bases in Logs screen, I know