Skip to content

Commit 0c462b6

Browse files
committed
Merge remote-tracking branch 'upstream/master' into loadout_copy_paste
Conflicts: src/Engine/Options.inc.h
2 parents 7062344 + 6bbc9a5 commit 0c462b6

52 files changed

Lines changed: 721 additions & 383 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ if ( GIT_FOUND )
107107
set ( git_nb_commit ${CMAKE_MATCH_2} )
108108
set ( git_commit ${CMAKE_MATCH_3} )
109109
set ( git_dirty ${CMAKE_MATCH_4} )
110+
add_definitions( -DOPENXCOM_VERSION_GIT="${git_commit}" )
110111
endif()
111112

112113
if ( DEV_BUILD )

bin/data/Language/en-GB.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ en-GB:
11471147
STR_GLOBESEASONS_DESC: "Uses more realistic projection of sunlight on the Geoscape according to Earth's axial tilt."
11481148
STR_PLAYINTRO: "Play intro"
11491149
STR_PLAYINTRO_DESC: "Show the intro cinematic on startup."
1150-
STR_SHOWMORESTATSININVENTORYVIEW: "Inventory extra stats"
1150+
STR_SHOWMORESTATSININVENTORYVIEW: "Inventory stats"
11511151
STR_SHOWMORESTATSININVENTORYVIEW_DESC: "Show extra information on the selected soldier in the inventory screen."
11521152
STR_SNEAKYAI: "Sneaky AI"
11531153
STR_SNEAKYAI_DESC: "AI avoids exposing themselves to the player whenever possible."
@@ -1228,8 +1228,8 @@ en-GB:
12281228
STR_LETTERBOXED: "Letterboxed"
12291229
STR_LETTERBOXED_DESC: "Letterboxes the display to maintain the original aspect ratio."
12301230
STR_RESIZABLE: "Resizable"
1231-
STR_LOCK_MOUSE: "Lock Mouse"
1232-
STR_LOCK_MOUSE_DESC: "Keeps the mouse cursor from leaving the game window. Not recommended for multitasking."
1231+
STR_LOCK_MOUSE: "Grab Mouse"
1232+
STR_LOCK_MOUSE_DESC: "Keeps the mouse cursor from leaving the game window. Ctrl+G to toggle at any time."
12331233
STR_MUSIC_VOLUME: "Music Volume"
12341234
STR_MUSIC_VOLUME_DESC: "Changes the volume of the background music."
12351235
STR_SFX_VOLUME: "SFX Volume"

bin/data/Language/en-US.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ en-US:
11471147
STR_GLOBESEASONS_DESC: "Uses more realistic projection of sunlight on the Geoscape according to Earth's axial tilt."
11481148
STR_PLAYINTRO: "Play intro"
11491149
STR_PLAYINTRO_DESC: "Show the intro cinematic on startup."
1150-
STR_SHOWMORESTATSININVENTORYVIEW: "Inventory extra stats"
1150+
STR_SHOWMORESTATSININVENTORYVIEW: "Inventory Stats"
11511151
STR_SHOWMORESTATSININVENTORYVIEW_DESC: "Show extra information on the selected soldier in the inventory screen."
11521152
STR_SNEAKYAI: "Sneaky AI"
11531153
STR_SNEAKYAI_DESC: "AI avoids exposing themselves to the player whenever possible."
@@ -1228,8 +1228,8 @@ en-US:
12281228
STR_LETTERBOXED: "Letterboxed"
12291229
STR_LETTERBOXED_DESC: "Letterboxes the display to maintain the original aspect ratio."
12301230
STR_RESIZABLE: "Resizable"
1231-
STR_LOCK_MOUSE: "Lock Mouse"
1232-
STR_LOCK_MOUSE_DESC: "Keeps the mouse cursor from leaving the game window. Not recommended for multitasking."
1231+
STR_LOCK_MOUSE: "Grab Mouse"
1232+
STR_LOCK_MOUSE_DESC: "Keeps the mouse cursor from leaving the game window. Ctrl+G to toggle at any time."
12331233
STR_MUSIC_VOLUME: "Music Volume"
12341234
STR_MUSIC_VOLUME_DESC: "Changes the volume of the background music."
12351235
STR_SFX_VOLUME: "SFX Volume"

bin/data/Ruleset/Xcom1Ruleset.rul

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ regions:
909909
- [207, 207.125, -21.625, -21.5]
910910
- [177.75, 178.25, 17.5, 17.875]
911911
- [164.625, 164.75, 20.5, 20.75]
912-
-
912+
-
913913
- [209.125, 209.625, -19.875, -19.375]
914914
- [207, 207.125, -21.625, -21.5]
915915
-
@@ -4415,6 +4415,7 @@ soldiers:
44154415
armor: STR_NONE_UC
44164416
standHeight: 22
44174417
kneelHeight: 14
4418+
genderRatio: [3, 1]
44184419
units:
44194420
- type: STR_TANK_CANNON
44204421
race: STR_TANK_CANNON

src/Basescape/BaseInfoState.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ BaseInfoState::BaseInfoState(Game *game, Base *base, BasescapeState *state) : St
178178
}
179179
}
180180
_mini->onMouseClick((ActionHandler)&BaseInfoState::miniClick);
181+
_mini->onKeyboardPress((ActionHandler)&BaseInfoState::handleKeyPress);
181182

182183
_btnOk->setColor(Palette::blockOffset(15)+6);
183184
_btnOk->setText(tr("STR_OK"));
@@ -423,6 +424,43 @@ void BaseInfoState::edtBaseChange(Action *action)
423424
_base->setName(_edtBase->getText());
424425
}
425426

427+
428+
/**
429+
* * Selects a new base to display.
430+
* * @param action Pointer to an action.
431+
* */
432+
void BaseInfoState::handleKeyPress(Action *action)
433+
{
434+
if (action->getDetails()->type == SDL_KEYDOWN)
435+
{
436+
SDLKey baseKeys[] = {Options::keyBaseSelect1,
437+
Options::keyBaseSelect2,
438+
Options::keyBaseSelect3,
439+
Options::keyBaseSelect4,
440+
Options::keyBaseSelect5,
441+
Options::keyBaseSelect6,
442+
Options::keyBaseSelect7,
443+
Options::keyBaseSelect8};
444+
int base = -1;
445+
int key = action->getDetails()->key.keysym.sym;
446+
for (size_t i = 0; i < MiniBaseView::MAX_BASES; ++i)
447+
{
448+
if (key == baseKeys[i])
449+
{
450+
base = i;
451+
break;
452+
}
453+
}
454+
if (base > -1 && base < _game->getSavedGame()->getBases()->size())
455+
{
456+
_mini->setSelectedBase(base);
457+
_base = _game->getSavedGame()->getBases()->at(base);
458+
_state->setBase(_base);
459+
init();
460+
}
461+
}
462+
}
463+
426464
/**
427465
* Selects a new base to display.
428466
* @param action Pointer to an action.

src/Basescape/BaseInfoState.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class BaseInfoState : public State
7070
void edtBaseChange(Action *action);
7171
/// Handler for clicking the mini base view.
7272
void miniClick(Action *action);
73+
/// Handler for selecting bases.
74+
void handleKeyPress(Action *action);
7375
/// Handler for clicking the OK button.
7476
void btnOkClick(Action *action);
7577
/// Handler for clicking the Transfers button.

src/Basescape/CraftEquipmentState.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -542,39 +542,26 @@ void CraftEquipmentState::moveRightByValue(int change)
542542
change = std::min(room, change);
543543
if(!item->getCompatibleAmmo()->empty())
544544
{
545-
// We want to redistribute all the available ammo among the vehicles,
546-
// so first we note the total number of vehicles we want in the craft
547-
int oldVehiclesCount = c->getVehicleCount(_items[_sel]);
548-
int newVehiclesCount = oldVehiclesCount + change;
549-
// ...and we move back all of this vehicle-type to the base.
550-
if (0 < oldVehiclesCount) moveLeftByValue(INT_MAX);
551545
// And now let's see if we can add the total number of vehicles.
552546
RuleItem *ammo = _game->getRuleset()->getItem(item->getCompatibleAmmo()->front());
553-
int baqty = _base->getItems()->getItem(ammo->getType()); // Ammo Quantity for this vehicle-type on the base
554-
int canBeAdded = std::min(newVehiclesCount, baqty);
547+
int ammoPerVehicle = ammo->getClipSize();
548+
int baseQty = _base->getItems()->getItem(ammo->getType()) / ammoPerVehicle;
549+
if (_game->getSavedGame()->getMonthsPassed() == -1)
550+
baseQty = 1;
551+
int canBeAdded = std::min(change, baseQty);
555552
if (canBeAdded > 0)
556553
{
557-
int newAmmoPerVehicle = std::min(baqty / canBeAdded, ammo->getClipSize());
558-
int remainder = 0;
559-
if (ammo->getClipSize() > newAmmoPerVehicle) remainder = baqty - (canBeAdded * newAmmoPerVehicle);
560-
int newAmmo;
561554
for (int i=0; i < canBeAdded; ++i)
562555
{
563-
newAmmo = newAmmoPerVehicle;
564-
if (i<remainder) ++newAmmo;
565556
if (_game->getSavedGame()->getMonthsPassed() != -1)
566557
{
567-
_base->getItems()->removeItem(ammo->getType(), newAmmo);
558+
_base->getItems()->removeItem(ammo->getType(), ammoPerVehicle);
568559
_base->getItems()->removeItem(_items[_sel]);
569560
}
570-
else
571-
{
572-
newAmmo = ammo->getClipSize();
573-
}
574-
c->getVehicles()->push_back(new Vehicle(item, newAmmo, size));
561+
c->getVehicles()->push_back(new Vehicle(item, ammoPerVehicle, size));
575562
}
576563
}
577-
if (oldVehiclesCount >= canBeAdded)
564+
else
578565
{
579566
// So we haven't managed to increase the count of vehicles because of the ammo
580567
_timerRight->stop();

src/Battlescape/BattlescapeGenerator.cpp

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,17 @@ void BattlescapeGenerator::deployXCOM()
457457
}
458458
}
459459

460+
// load weapons before distribution, even before loadouts
461+
// loading weapons take priority over extra clips.
462+
loadWeapons();
463+
460464
// equip soldiers based on equipment-layout
461465
for (std::vector<BattleItem*>::iterator i = _craftInventoryTile->getInventory()->begin(); i != _craftInventoryTile->getInventory()->end(); ++i)
462466
{
463467
placeItemByLayout(*i);
464468
}
465469

470+
466471
// auto-equip soldiers (only soldiers without layout)
467472
for (int pass = 0; pass != 4; ++pass)
468473
{
@@ -853,8 +858,10 @@ bool BattlescapeGenerator::placeItemByLayout(BattleItem *item)
853858
for (std::vector<BattleUnit*>::iterator i = _save->getUnits()->begin(); i != _save->getUnits()->end(); ++i)
854859
{
855860
// skip the vehicles, we need only X-Com soldiers WITH equipment-layout
856-
if ((*i)->getArmor()->getSize() > 1 || 0 == (*i)->getGeoscapeSoldier()) continue;
857-
if ((*i)->getGeoscapeSoldier()->getEquipmentLayout()->empty()) continue;
861+
if ((*i)->getArmor()->getSize() > 1 || !(*i)->getGeoscapeSoldier() || (*i)->getGeoscapeSoldier()->getEquipmentLayout()->empty())
862+
{
863+
continue;
864+
}
858865

859866
// find the first matching layout-slot which is not already occupied
860867
std::vector<EquipmentLayoutItem*> *layoutItems = (*i)->getGeoscapeSoldier()->getEquipmentLayout();
@@ -863,23 +870,13 @@ bool BattlescapeGenerator::placeItemByLayout(BattleItem *item)
863870
if (item->getRules()->getType() != (*j)->getItemType()
864871
|| (*i)->getItem((*j)->getSlot(), (*j)->getSlotX(), (*j)->getSlotY())) continue;
865872

866-
if ("NONE" == (*j)->getAmmoItem())
873+
if ((*j)->getAmmoItem() == "NONE")
874+
{
867875
loaded = true;
876+
}
868877
else
869878
{
870-
loaded = false;
871-
// maybe we find the layout-ammo on the ground to load it with
872-
for (std::vector<BattleItem*>::iterator k = _craftInventoryTile->getInventory()->begin(); (!loaded) && k != _craftInventoryTile->getInventory()->end(); ++k)
873-
{
874-
if ((*k)->getRules()->getType() == (*j)->getAmmoItem() && (*k)->getSlot() == ground
875-
&& item->setAmmoItem((*k)) == 0)
876-
{
877-
_save->getItems()->push_back(*k);
878-
(*k)->setSlot(righthand);
879-
loaded = true;
880-
// note: soldier is not owner of the ammo, we are using this fact when saving equipments
881-
}
882-
}
879+
loaded = item->getAmmoItem() || item->getRules()->getCompatibleAmmo()->empty();
883880
}
884881
// only place the weapon onto the soldier when it's loaded with its layout-ammo (if any)
885882
if (loaded)
@@ -963,26 +960,10 @@ bool BattlescapeGenerator::addItem(BattleItem *item, BattleUnit *unit, bool allo
963960
{
964961
loaded = true;
965962
}
966-
if (unit->getFaction() == FACTION_PLAYER)
967-
{
968-
// let's try to load this weapon, whether we equip it or not.
969-
for (std::vector<BattleItem*>::iterator i = _craftInventoryTile->getInventory()->begin(); i != _craftInventoryTile->getInventory()->end() && !loaded; ++i)
970-
{
971-
if ((*i)->getSlot() == ground && item->setAmmoItem((*i)) == 0)
972-
{
973-
_save->getItems()->push_back(*i);
974-
(*i)->setXCOMProperty(true);
975-
(*i)->setSlot(rightHand);
976-
weight += (*i)->getRules()->getWeight();
977-
loaded = true;
978-
// note: soldier is not owner of the ammo, we are using this fact when saving equipments
979-
}
980-
}
981-
}
982963

983964
if (loaded && (unit->getGeoscapeSoldier() == 0 || _allowAutoLoadout))
984965
{
985-
if (!unit->getItem("STR_RIGHT_HAND") && unit->getStats()->strength * 0.66 >= weight)
966+
if (!unit->getItem("STR_RIGHT_HAND") && unit->getStats()->strength * 0.66 >= weight) // weight is always considered 0 for aliens
986967
{
987968
item->moveToOwner(unit);
988969
item->setSlot(rightHand);
@@ -1013,7 +994,7 @@ bool BattlescapeGenerator::addItem(BattleItem *item, BattleUnit *unit, bool allo
1013994
default:
1014995
if ((unit->getGeoscapeSoldier() == 0 || _allowAutoLoadout))
1015996
{
1016-
if (unit->getStats()->strength >= weight)
997+
if (unit->getStats()->strength >= weight) // weight is always considered 0 for aliens
1017998
{
1018999
for (std::vector<std::string>::const_iterator i = _game->getRuleset()->getInvsList().begin(); i != _game->getRuleset()->getInvsList().end() && !placed; ++i)
10191000
{
@@ -1919,4 +1900,41 @@ void BattlescapeGenerator::runInventory(Craft *craft)
19191900
delete set;
19201901
}
19211902

1903+
/**
1904+
* Loads all XCom weaponry before anything else is distributed.
1905+
*/
1906+
void BattlescapeGenerator::loadWeapons()
1907+
{
1908+
// let's try to load this weapon, whether we equip it or not.
1909+
for (std::vector<BattleItem*>::iterator i = _craftInventoryTile->getInventory()->begin(); i != _craftInventoryTile->getInventory()->end(); ++i)
1910+
{
1911+
if (!(*i)->getRules()->isFixed() &&
1912+
!(*i)->getRules()->getCompatibleAmmo()->empty() &&
1913+
(*i)->getAmmoItem() == 0 &&
1914+
((*i)->getRules()->getBattleType() == BT_FIREARM || (*i)->getRules()->getBattleType() == BT_MELEE))
1915+
{
1916+
bool loaded = false;
1917+
for (std::vector<BattleItem*>::iterator j = _craftInventoryTile->getInventory()->begin(); j != _craftInventoryTile->getInventory()->end() && !loaded; ++j)
1918+
{
1919+
if ((*j)->getSlot() == _game->getRuleset()->getInventory("STR_GROUND") && (*i)->setAmmoItem((*j)) == 0)
1920+
{
1921+
_save->getItems()->push_back(*j);
1922+
(*j)->setXCOMProperty(true);
1923+
(*j)->setSlot(_game->getRuleset()->getInventory("STR_RIGHT_HAND"));
1924+
loaded = true;
1925+
}
1926+
}
1927+
}
1928+
}
1929+
for (std::vector<BattleItem*>::iterator i = _craftInventoryTile->getInventory()->begin(); i != _craftInventoryTile->getInventory()->end();)
1930+
{
1931+
if ((*i)->getSlot() != _game->getRuleset()->getInventory("STR_GROUND"))
1932+
{
1933+
i = _craftInventoryTile->getInventory()->erase(i);
1934+
continue;
1935+
}
1936+
++i;
1937+
}
1938+
1939+
}
19221940
}

src/Battlescape/BattlescapeGenerator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class BattlescapeGenerator
128128
bool placeUnitNearFriend(BattleUnit *unit);
129129
/// Generates an inventory battlescape.
130130
void runInventory(Craft *craft);
131+
/// Load all Xcom weapons.
132+
void loadWeapons();
131133
};
132134

133135
}

src/Battlescape/BattlescapeState.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ void BattlescapeState::mapOver(Action *action)
610610
_mouseMovedOverThreshold = ((std::abs(_totalMouseMoveX) > Options::dragScrollPixelTolerance) || (std::abs(_totalMouseMoveY) > Options::dragScrollPixelTolerance));
611611

612612
// Scrolling
613-
if (Options::dragScrollInvert)
613+
if (Options::battleDragScrollInvert)
614614
{
615615
_map->getCamera()->scrollXY(
616616
-action->getDetails()->motion.xrel,
@@ -1434,8 +1434,8 @@ inline void BattlescapeState::handle(Action *action)
14341434
_save->setDebugMode();
14351435
debug(L"Debug Mode");
14361436
}
1437-
// "ctrl-l" - reset tile visibility
1438-
else if (_save->getDebugMode() && action->getDetails()->key.keysym.sym == SDLK_l && (SDL_GetModState() & KMOD_CTRL) != 0)
1437+
// "ctrl-v" - reset tile visibility
1438+
else if (_save->getDebugMode() && action->getDetails()->key.keysym.sym == SDLK_v && (SDL_GetModState() & KMOD_CTRL) != 0)
14391439
{
14401440
debug(L"Resetting tile visibility");
14411441
_save->resetTiles();
@@ -2062,6 +2062,8 @@ void BattlescapeState::resize(int &dX, int &dY)
20622062
case SCALE_SCREEN:
20632063
break;
20642064
default:
2065+
dX = 0;
2066+
dY = 0;
20652067
return;
20662068
}
20672069

0 commit comments

Comments
 (0)