Index: binaries/data/mods/public/gui/session/input.js
===================================================================
--- binaries/data/mods/public/gui/session/input.js (Revision 23690)
+++ binaries/data/mods/public/gui/session/input.js (Arbeitskopie)
@@ -299,7 +299,8 @@
return false;
}
- var selection = g_Selection.toList();
+ let selection = Engine.HotkeyIsPressed("session.orderone") &&
+ popOneFromSelection({ "type": "construct", "target": placementSupport }) || g_Selection.toList();
Engine.PostNetworkCommand({
"type": "construct",
@@ -331,8 +332,8 @@
return false;
}
- var wallPlacementInfo = updateBuildingPlacementPreview(); // entities making up the wall (wall segments, towers, ...)
- if (!(wallPlacementInfo === false || typeof(wallPlacementInfo) === "object"))
+ let wallPlacementInfo = updateBuildingPlacementPreview(); // entities making up the wall (wall segments, towers, ...)
+ if (!(wallPlacementInfo === false || typeof wallPlacementInfo === "object"))
{
error("Invalid updateBuildingPlacementPreview return value: " + uneval(wallPlacementInfo));
return false;
@@ -341,8 +342,10 @@
if (!wallPlacementInfo)
return false;
- var selection = g_Selection.toList();
- var cmd = {
+ let selection = Engine.HotkeyIsPressed("session.orderone") &&
+ popOneFromSelection({ "type": "construct", "target": placementSupport }) || g_Selection.toList();
+
+ let cmd = {
"type": "construct-wall",
"autorepair": true,
"autocontinue": true,
@@ -357,7 +360,7 @@
// make sure that there's at least one non-tower entity getting built, to prevent silly edge cases where the start and end
// point are too close together for the algorithm to place a wall segment inbetween, and only the towers are being previewed
// (this is somewhat non-ideal and hardcode-ish)
- var hasWallSegment = false;
+ let hasWallSegment = false;
for (let piece of cmd.pieces)
{
if (piece.template != cmd.wallSet.templates.tower) // TODO: hardcode-ish :(
@@ -1144,6 +1147,18 @@
return handleUnitAction(Engine.GetTerrainAtScreenPoint(ev.x, ev.y), action);
}
+function popOneFromSelection(action)
+{
+ // Pick the first unit that can do this order.
+ let unit = g_Selection.find(entity =>
+ ["preSelectedActionCheck", "hotkeyActionCheck", "actionCheck"].some(method =>
+ g_UnitActions[action.type][method] &&
+ g_UnitActions[action.type][method](action.target || undefined, [entity])
+ ));
+ if (unit)
+ return g_Selection.removeList([unit]), [unit];
+ return null;
+}
function positionUnitsFreehandSelectionMouseMove(ev)
{
@@ -1236,22 +1251,8 @@
return false;
}
- let selection = g_Selection.toList();
- if (Engine.HotkeyIsPressed("session.orderone"))
- {
- // Pick the first unit that can do this order.
- let unit = selection.find(entity =>
- ["preSelectedActionCheck", "hotkeyActionCheck", "actionCheck"].some(method =>
- g_UnitActions[action.type][method] &&
- g_UnitActions[action.type][method](action.target || undefined, [entity])
- ));
- if (unit)
- {
- selection = [unit];
- g_Selection.removeList(selection);
- }
- }
-
+ let selection = Engine.HotkeyIsPressed("session.orderone") &&
+ popOneFromSelection(action) || g_Selection.toList();
// If the session.queue hotkey is down, add the order to the unit's order queue instead
// of running it immediately
return g_UnitActions[action.type].execute(target, action, selection, Engine.HotkeyIsPressed("session.queue"));
Index: binaries/data/mods/public/gui/session/selection.js
===================================================================
--- binaries/data/mods/public/gui/session/selection.js (Revision 23690)
+++ binaries/data/mods/public/gui/session/selection.js (Arbeitskopie)
@@ -390,6 +390,14 @@
return ents;
};
+EntitySelection.prototype.find = function(condition)
+{
+ for (let ent in this.selected)
+ if (condition(ent))
+ return +ent;
+ return null;
+};
+
EntitySelection.prototype.setHighlightList = function(ents)
{
var highlighted = {};
Index: binaries/data/mods/public/gui/session/unit_actions.js
===================================================================
--- binaries/data/mods/public/gui/session/unit_actions.js (Revision 23690)
+++ binaries/data/mods/public/gui/session/unit_actions.js (Arbeitskopie)
@@ -340,6 +340,20 @@
"specificness": 7,
},
+ // "Fake" action to check if an entity can be ordered to "construct"
+ // which is handled differently from repair as the target does not exist.
+ "construct":
+ {
+ "preSelectedActionCheck": function(target, selection)
+ {
+ let state = GetEntityState(selection[0]);
+ if (state && state.builder && target.constructor.name == "PlacementSupport")
+ return { "type": "construct" };
+ return false;
+ },
+ "specificness": 0,
+ },
+
"repair":
{
"execute": function(target, action, selection, queued)
Index: source/third_party/tinygettext/src/plural_forms.cpp
===================================================================
--- source/third_party/tinygettext/src/plural_forms.cpp (Revision 23690)
+++ source/third_party/tinygettext/src/plural_forms.cpp (Arbeitskopie)
@@ -57,7 +57,9 @@
unsigned int plural4_gd(int n) { return static_cast<unsigned int>(( n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3); }
unsigned int plural4_he(int n) { return static_cast<unsigned int>((n == 1 && n % 1 == 0) ? 0 : (n == 2 && n % 1 == 0) ? 1: (n % 10 == 0 && n % 1 == 0 && n > 10) ? 2 : 3);}
unsigned int plural4_lt(int n) { return static_cast<unsigned int>(n % 10 == 1 && (n % 100 > 19 || n % 100 < 11) ? 0 : (n % 10 >= 2 && n % 10 <=9) && (n % 100 > 19 || n % 100 < 11) ? 1 : n % 1 != 0 ? 2: 3);}
+#pragma GCC diagnostic ignored "-Wparentheses"
unsigned int plural4_pl(int n) { return static_cast<unsigned int>(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);}
+#pragma GCC diagnostic pop
unsigned int plural4_sk(int n) { return static_cast<unsigned int>(n % 1 == 0 && n == 1 ? 0 : n % 1 == 0 && n >= 2 && n <= 4 ? 1 : n % 1 != 0 ? 2: 3);}
unsigned int plural4_uk(int n) { return static_cast<unsigned int>(n % 1 == 0 && n % 10 == 1 && n % 100 != 11 ? 0 : n % 1 == 0 && n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14) ? 1 : n % 1 == 0 && (n % 10 ==0 || (n % 10 >=5 && n % 10 <=9) || (n % 100 >=11 && n % 100 <=14 )) ? 2: 3);}
unsigned int plural5_ga(int n) { return static_cast<unsigned int>(n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4);}