Changeset View
Standalone View
binaries/data/mods/public/gui/session/input.js
Context not available. | |||||
const INPUT_BUILDING_WALL_CLICK = 8; | const INPUT_BUILDING_WALL_CLICK = 8; | ||||
const INPUT_BUILDING_WALL_PATHING = 9; | const INPUT_BUILDING_WALL_PATHING = 9; | ||||
const INPUT_MASSTRIBUTING = 10; | const INPUT_MASSTRIBUTING = 10; | ||||
const INPUT_RIGHT = 11; | |||||
elexis: The state should not be named according to the virtual key pressed, but to the consequential… | |||||
const INPUT_UNIT_POSITION = 12; | |||||
var inputState = INPUT_NORMAL; | var inputState = INPUT_NORMAL; | ||||
Context not available. | |||||
var mouseY = 0; | var mouseY = 0; | ||||
var mouseIsOverObject = false; | var mouseIsOverObject = false; | ||||
// Input line | |||||
var g_FreehandSelection_InputLine = []; | |||||
Done Inline Actionsglobals should be g_Foo (input.js has it wrong, but better add it correctly than having to change it later) elexis: globals should be `g_Foo` (`input.js` has it wrong, but better add it correctly than having to… | |||||
Done Inline Actionsa sentence should end with a period bb: a sentence should end with a period | |||||
Not Done Inline ActionsThe ingame positions the units will take up or just GUI screenspace coordinates that don't relate to the units yet? elexis: The ingame positions the units will take up or just GUI screenspace coordinates that don't… | |||||
const g_FreehandSelection_ResolutionInputLine = 1; | |||||
const g_FreehandSelection_MinLengthOfLine = 8; | |||||
Done Inline Actions(I actually meant all 3 could be const, so only the upper one is a var) bb: (I actually meant all 3 could be const, so only the upper one is a var) | |||||
const g_FreehandSelection_MinNumberOfUnits = 2; // Minmum must be 2, for better performance set it higher | |||||
Done Inline ActionsWe should find a unique catchy name like freehand selection, freehand formation, or input line and then make it g_Name_Property, so tht it is easily distinguished from other globals and so that the reader knows the connotation immediately even if there is no danger of confusion elexis: We should find a unique catchy name like freehand selection, freehand formation, or input line… | |||||
Done Inline Actionsto make code clearer, these could be const bb: to make code clearer, these could be const | |||||
Done Inline ActionsWhy not make it 2 then? bb: Why not make it 2 then? | |||||
bbUnsubmitted Done Inline ActionsMinimum bb: Min**i**mum | |||||
Not Done Inline ActionsThe JSdoc comment missing here could state that this is a minimum distance between units. elexis: The JSdoc comment missing here could state that this is a minimum distance between units. | |||||
// Number of pixels the mouse can move before the action is considered a drag | // Number of pixels the mouse can move before the action is considered a drag | ||||
Done Inline ActionsIf we have comments, they should use JSdoc. elexis: If we have comments, they should use JSdoc.
Globals should have one brief information (i.e. | |||||
Not Done Inline Actionsthese two should have a comment elexis: these two should have a comment | |||||
var maxDragDelta = 4; | var maxDragDelta = 4; | ||||
Done Inline Actionsperiods bb: periods | |||||
Context not available. | |||||
} | } | ||||
break; | break; | ||||
case INPUT_UNIT_POSITION: | |||||
switch (ev.type) | |||||
{ | |||||
case "mousemotion": | |||||
return positionUnitsFreehandSelectionMouseMove(ev); | |||||
case "mousebuttonup": | |||||
return positionUnitsFreehandSelectionMouseUp(ev); | |||||
} | |||||
break; | |||||
case INPUT_BUILDING_CLICK: | case INPUT_BUILDING_CLICK: | ||||
switch (ev.type) | switch (ev.type) | ||||
{ | { | ||||
Done Inline Actions(Why take the square but not the other function from that commit?) elexis: (Why take the square but not the other function from that commit?) | |||||
Done Inline ActionsCould use some bipartite weighted matching algorithm. Imarok: Could use some bipartite weighted matching algorithm.
For example the Hungarian algorithm… | |||||
Done Inline ActionsThe Hungarian algorithm gives you the shortest path for all paths together. But I think we need the shortest max. singlepath. OptimusShepard: The Hungarian algorithm gives you the shortest path for all paths together. But I think we need… | |||||
Done Inline ActionsThen look into bottleneck matching Imarok: Then look into bottleneck matching | |||||
Done Inline ActionsI think this could be an own ticket to find and optimize the algorithm. OptimusShepard: I think this could be an own ticket to find and optimize the algorithm. | |||||
Done Inline Actionsno Imarok: no | |||||
Context not available. | |||||
case "mousebuttondown": | case "mousebuttondown": | ||||
if (ev.button == SDL_BUTTON_LEFT) | if (ev.button == SDL_BUTTON_LEFT) | ||||
{ | { | ||||
dragStart = [ ev.x, ev.y ]; | dragStart = [ev.x, ev.y]; | ||||
Done Inline Actionsshould become a Vector2D, can use Vector2D.sub and distanceTo then to simplify the code a bit elexis: should become a Vector2D, can use Vector2D.sub and `distanceTo` then to simplify the code a bit | |||||
inputState = INPUT_SELECTING; | inputState = INPUT_SELECTING; | ||||
// If a single click occured, reset the clickedEntity. | // If a single click occured, reset the clickedEntity. | ||||
// Also set it if we're double/triple clicking and missed the unit earlier. | // Also set it if we're double/triple clicking and missed the unit earlier. | ||||
Context not available. | |||||
} | } | ||||
else if (ev.button == SDL_BUTTON_RIGHT) | else if (ev.button == SDL_BUTTON_RIGHT) | ||||
{ | { | ||||
var action = determineAction(ev.x, ev.y); | dragStart = [ev.x, ev.y]; | ||||
elexisUnsubmitted Done Inline ActionsSure dragStart isn't better off as a new Vector2D if we're already creating a new object? elexis: Sure `dragStart` isn't better off as a new Vector2D if we're already creating a new object? | |||||
OptimusShepardAuthorUnsubmitted Done Inline ActionsThat should be done in another patch. "dragStart" is used global in a few functions OptimusShepard: That should be done in another patch. "dragStart" is used global in a few functions | |||||
if (!action) | inputState = INPUT_RIGHT; | ||||
break; | |||||
return doAction(action, ev); | |||||
} | } | ||||
break; | break; | ||||
Done Inline Actionswe do not put spaces after [ and before ] bb: we do not put spaces after `[` and before `]` | |||||
Not Done Inline ActionsWould be candy if C++ provides us the vector right away :-) elexis: Would be candy if C++ provides us the vector right away :-) | |||||
Context not available. | |||||
} | } | ||||
break; | break; | ||||
case INPUT_RIGHT: | |||||
switch (ev.type) | |||||
Not Done Inline ActionsNot cool in the long-term that this is hardcoded to the right-button. elexis: Not cool in the long-term that this is hardcoded to the right-button.
I have a trac ticket for… | |||||
{ | |||||
case "mousemotion": | |||||
// If the mouse moved further than a limit, switch to unit position mode | |||||
let dragDeltaX = ev.x - dragStart[0]; | |||||
let dragDeltaY = ev.y - dragStart[1]; | |||||
Not Done Inline Actionssquare bb: square | |||||
Not Done Inline ActionsIn my opinion vector are much better for readabilty. It also isn't performance criticaly. But I will change it if you and elexis come to an agreement. OptimusShepard: In my opinion vector are much better for readabilty. It also isn't performance criticaly. But I… | |||||
Not Done Inline Actionsg_DragStart.distanceTo(ev) >= g_MaxDragDelta vs g_DragStart.distanceToSquared(ev) >= g_MaxDragDelta * g_MaxDragDelta don't see the readability drain bb: `g_DragStart.distanceTo(ev) >= g_MaxDragDelta` vs `g_DragStart.distanceToSquared(ev) >=… | |||||
if (Math.abs(dragDeltaX) >= maxDragDelta || Math.abs(dragDeltaY) >= maxDragDelta) | |||||
Done Inline Actionscompare the squares for performance, also sqrt takes only one argument, bb: compare the squares for performance, also sqrt takes only one argument,
we should check… | |||||
Done Inline Actionssee above, "dragStart" is global used and I think it should be changed all over in another patch OptimusShepard: see above, "dragStart" is global used and I think it should be changed all over in another… | |||||
{ | |||||
inputState = INPUT_UNIT_POSITION; | |||||
return false; | |||||
} | |||||
break; | |||||
case "mousebuttonup": | |||||
Not Done Inline Actionscould compare the squares for performance bb: could compare the squares for performance | |||||
Not Done Inline ActionsI don't think we have performance problem here? It is only used once OptimusShepard: I don't think we have performance problem here? It is only used once | |||||
Not Done Inline ActionsIs there any difference on performance? If I take square, there is one operation less on "g_DragStart.distanceTo(ev)" but one more operation on g_MaxDragDelta? OptimusShepard: Is there any difference on performance? If I take square, there is one operation less on… | |||||
Not Done Inline Actionsbut a sqrt is much more a performance drain that a square, also even if it isn't performance critical every little thing helps, and code executes the same bb: but a sqrt is much more a performance drain that a square, also even if it isn't performance… | |||||
inputState = INPUT_NORMAL; | |||||
if (ev.button == SDL_BUTTON_RIGHT) | |||||
{ | |||||
let action = determineAction(ev.x, ev.y); | |||||
if (action) | |||||
return doAction(action, ev); | |||||
} | |||||
break; | |||||
} | |||||
break; | |||||
case INPUT_BUILDING_PLACEMENT: | case INPUT_BUILDING_PLACEMENT: | ||||
switch (ev.type) | switch (ev.type) | ||||
{ | { | ||||
Done Inline Actions(Always use let instead of var so that the reader only has to consider the scope that the variable is defined in. Also the variable is used only once so can be inlined.) elexis: (Always use `let` instead of `var` so that the reader only has to consider the scope that the… | |||||
Done Inline Actions-1 tab elexis: -1 tab | |||||
Done Inline ActionsWhy not: if (action) return doAction...; There is already a break on L1085 Imarok: Why not:
```
if (action)
return doAction...;
```
There is already a break on L1085 | |||||
Done Inline ActionsWould returning in both cases (return action && doAction) be correct? elexis: Would returning in both cases (`return action && doAction`) be correct?
It's hard to see… | |||||
Done Inline ActionsI think I have to return true. OptimusShepard: I think I have to return true. | |||||
Done Inline Actionswhy not the euclidic distance? Imarok: why not the euclidic distance?
like this it triggers at different limits depending on the… | |||||
Context not available. | |||||
return false; | return false; | ||||
} | } | ||||
function positionUnitsFreehandSelectionMouseMove(ev) | |||||
Done Inline ActionsMouseMove bb: MouseMove | |||||
{ | |||||
// Convert the input line into a List of points, | |||||
// for better performance the points have to have a minimum distance to each other | |||||
let target = Engine.GetTerrainAtScreenPoint(ev.x, ev.y); | |||||
Done Inline ActionsVector2D.from3D elexis: Vector2D.from3D | |||||
let p = new Vector2D(target.x, target.z); | |||||
Done Inline Actionswasn't the argument to change these lines in a previous iteration that it is a different distance for different directions? bb: wasn't the argument to change these lines in a previous iteration that it is a different… | |||||
Not Done Inline Actionstarget.distanceToSquared(g_FreehandSelection_InputLine[g_FreehandSelection_InputLine.length - 1]) bb: target.distanceToSquared(g_FreehandSelection_InputLine[g_FreehandSelection_InputLine.length… | |||||
if (!g_FreehandSelection_InputLine.length || | |||||
Done Inline ActionsI would have said target.distanceToSquared(FreehandSelection_InputLine[g_FreehandSelection_InputLine.length - 1]), but this one might be faster. elexis: I would have said `target.distanceToSquared(FreehandSelection_InputLine… | |||||
Done Inline Actionsyes you'r right, thx. OptimusShepard: yes you'r right, thx. | |||||
Not Done Inline Actionscould store the square as it is only used here bb: could store the square as it is only used here | |||||
p.distanceTo(g_FreehandSelection_InputLine[g_FreehandSelection_InputLine.length - 1]) >= g_FreehandSelection_ResolutionInputLine) | |||||
Not Done Inline ActionsOk not to use distanceTo or distanceToSquared as it's executed per mousemove. elexis: Ok not to use distanceTo or distanceToSquared as it's executed per mousemove. | |||||
g_FreehandSelection_InputLine.push(p); | |||||
return false; | |||||
Done Inline Actionslanguage Imarok: language | |||||
} | |||||
function positionUnitsFreehandSelectionMouseUp(ev) | |||||
Done Inline Actionsalso could compare the squares for performance bb: also could compare the squares for performance | |||||
Done Inline ActionsI also think here isn't a performace problem. But if you think so, I could change it OptimusShepard: I also think here isn't a performace problem. But if you think so, I could change it | |||||
{ | |||||
inputState = INPUT_NORMAL; | |||||
let inputLine = g_FreehandSelection_InputLine; | |||||
g_FreehandSelection_InputLine = []; | |||||
if (ev.button == SDL_BUTTON_RIGHT) | |||||
{ | |||||
Done Inline Actionsalso taking the square helps for performance (one could also store the resolutionSquared for even better performance) bb: also taking the square helps for performance (one could also store the resolutionSquared for… | |||||
Done Inline Actionsit isn't the same like bevore. But I think this is ok. It also have better performance I think OptimusShepard: it isn't the same like bevore. But I think this is ok. It also have better performance I think | |||||
let lengthOfLine = 0; | |||||
for (let i = 1; i < inputLine.length; ++i) | |||||
lengthOfLine += inputLine[i].distanceTo(inputLine[i-1]); | |||||
Done Inline Actionsreturn if !right elexis: return if !right | |||||
let selection = g_Selection.toList().filter(ent => GetEntityState(ent).unitAI); | |||||
// If the line is to short the units will walk to the end of the line | |||||
if (lengthOfLine < g_FreehandSelection_MinLengthOfLine || selection.length < g_FreehandSelection_MinNumberOfUnits) | |||||
Done Inline Actionsspaces around - bb: spaces around `-` | |||||
{ | |||||
let action = determineAction(ev.x, ev.y); | |||||
Done Inline Actionslet elexis: let | |||||
return action && doAction(action, ev); | |||||
} | |||||
Done Inline Actionslanguage Imarok: language | |||||
else | |||||
{ | |||||
// Even distribution of the units on the line | |||||
let p0 = inputLine[0]; | |||||
let entityDistribution = [p0]; | |||||
let distanceBetweenEnts = lengthOfLine / (selection.length - 1); | |||||
Done Inline Actionscould be let p0 = inputLine[0]; let entityDistribution = [p0]; bb: could be
```
let p0 = inputLine[0];
let entityDistribution = [p0]; | |||||
Done Inline Actionsno else after return elexis: no else after return | |||||
let d = -distanceBetweenEnts; | |||||
Done Inline Actionsmaybe freeDist bb: maybe `freeDist` | |||||
for (let i = 1; i < inputLine.length; ++i) | |||||
{ | |||||
Done Inline Actionsmin => minimum bb: min => minimum | |||||
let p1 = inputLine[i]; | |||||
d += inputLine[i-1].distanceTo(p1); | |||||
Done Inline Actionscould use p1 bb: could use p1 | |||||
Done Inline ActionsThat magic number 1 should become a global, so that the meaning is expressed in the variable name and it can be changed without reading the code. elexis: That magic number 1 should become a global, so that the meaning is expressed in the variable… | |||||
while (d >= 0) | |||||
Done Inline Actions!...length elexis: `!...length` | |||||
{ | |||||
p0 = Vector2D.sub(p0, p1).normalize().mult(d).add(p1); | |||||
entityDistribution.push(p0); | |||||
d -= distanceBetweenEnts; | |||||
} | |||||
} | |||||
Done Inline Actionsmissing points and is that comma correct? bb: `missing points` and is that comma correct? | |||||
Done Inline Actions(unneeded commment) elexis: (unneeded commment) | |||||
Done Inline Actionstechnically check unneeded, I am fine with keeping them (yellers may yell) bb: technically check unneeded, I am fine with keeping them (yellers may yell) | |||||
// Rounding errors can lead to missing points | |||||
Done Inline ActionsCould be merged like this? let p = ... if (...) g_InputLine.push(p); Imarok: Could be merged like this?
```
let p = ...
if (...)
g_InputLine.push(p);
``` | |||||
if (selection.length > entityDistribution.length) | |||||
Done Inline Actions(Besides the braces of that if not being needed, the if itself is not needed / implied by the loop either, right? elexis: (Besides the braces of that if not being needed, the if itself is not needed / implied by the… | |||||
entityDistribution.push(inputLine[inputLine.length - 1]); | |||||
selection.sort((a, b) => a - b); | |||||
Done Inline Actionsshould work with for...of too elexis: should work with `for...of` too | |||||
Done Inline Actions(comment implies there could be more that 1 point missing, but code doesn't handle that) bb: (comment implies there could be more that 1 point missing, but code doesn't handle that) | |||||
Done Inline ActionsYou're right. I changed the comment. If there is once a time happen that two points are missing than one of the units will stay ground, no bug. I think this is ok OptimusShepard: You're right. I changed the comment. If there is once a time happen that two points are missing… | |||||
Done Inline Actionsmissing or too many elexis: missing or too many
Isn't that one too many at most? | |||||
Done Inline ActionsMostly there is one missing point. In my tests I've never had too much points. But if it that will happen I agree with bb that this could course an error OptimusShepard: Mostly there is one missing point. In my tests I've never had too much points. But if it that… | |||||
let firstUnit = GetEntityState(selection[0]); | |||||
Not Done Inline Actionsgood line spacing, but would like 4 spaces in front, so we have the different terms nicely alligned bb: good line spacing, but would like 4 spaces in front, so we have the different terms nicely… | |||||
let lastUnit = GetEntityState(selection[selection.length-1]); | |||||
Done Inline Actionsinline bb: inline | |||||
let firstToFirstDist = Math.euclidDistance2D(entityDistribution[0].x, entityDistribution[0].y, firstUnit.position.x, firstUnit.position.z); | |||||
let firstToLastDist = Math.euclidDistance2D(entityDistribution[selection.length-1].x, entityDistribution[selection.length-1].y, firstUnit.position.x, firstUnit.position.z); | |||||
elexisUnsubmitted Done Inline Actionsvector1.distanceTo(vector2) elexis: vector1.distanceTo(vector2) | |||||
OptimusShepardAuthorUnsubmitted Done Inline Actionsdoesn't work because of position.z OptimusShepard: doesn't work because of position.z
maybe we need new vector functions? | |||||
elexisUnsubmitted Done Inline ActionsThere is Vector2D.from3D and Vector3D.horizDistanceTo. But only do it if it's not a performance critical part (as far as I see it isn't). elexis: There is `Vector2D.from3D` and `Vector3D.horizDistanceTo`. But only do it if it's not a… | |||||
Done Inline Actionsinline that in L1186 bb: inline that in L1186 | |||||
let lastToFirstDist = Math.euclidDistance2D(entityDistribution[0].x, entityDistribution[0].y, lastUnit.position.x, lastUnit.position.z); | |||||
Done Inline ActionsI'd probably set this a lot higher. temple: I'd probably set this a lot higher. | |||||
Done Inline Actions-> global elexis: -> global | |||||
Done Inline Actionsuse a cap bb: use a cap | |||||
let lastToLastDist = Math.euclidDistance2D(entityDistribution[selection.length-1].x, entityDistribution[selection.length-1].y, lastUnit.position.x, lastUnit.position.z); | |||||
Done Inline Actionsis there a real need for the minlength? bb: is there a real need for the minlength? | |||||
Done Inline Actionsa to small line, isn't that usefull, but it could cost a lot of performance OptimusShepard: a to small line, isn't that usefull, but it could cost a lot of performance | |||||
Done Inline Actionsok bb: ok | |||||
Done Inline Actionsmany points bb: many points | |||||
Done Inline Actionsspaces around - (same below) bb: spaces around `-` (same below) | |||||
if (((firstToFirstDist < firstToLastDist) && (lastToFirstDist > lastToLastDist)) || | |||||
Done Inline ActionsIf one wants to take into account multiple points missing, one could (check theoretically unneeded that way) bb: If one wants to take into account multiple points missing, one could
`entityDistribution =… | |||||
((firstToFirstDist < firstToLastDist) && (firstToFirstDist > lastToFirstDist)) || | |||||
Done Inline Actionselse if bb: else if
(Theoretically check isn't needed) | |||||
Not Done Inline Actionsno targetclasses defined, throws warning when testing attack-walk, bb: no targetclasses defined, throws warning when testing attack-walk,
needs to add… | |||||
((lastToLastDist < lastToFirstDist) && (lastToLastDist > firstToLastDist))) | |||||
elexisUnsubmitted Done Inline Actionsunneeded parentheses, && binds stronge than || like * and +, in doubt lookup "operator precedence" elexis: unneeded parentheses, && binds stronge than || like * and +, in doubt lookup "operator… | |||||
Done Inline Actions(could be slice aswel, no strong opinion) bb: (could be slice aswel, no strong opinion) | |||||
{ | |||||
for (let i in entityDistribution) | |||||
Done Inline Actionswe doesn't seem to need the index, so we should use for ...of bb: we doesn't seem to need the index, so we should use for ...of
Also perhaps `i`=> `pos` | |||||
Done Inline ActionsI think since code had changed, "i" is better? OptimusShepard: I think since code had changed, "i" is better? | |||||
{ | |||||
Engine.PostNetworkCommand({ | |||||
Done Inline Actionslet reworkedLine = [inputLine[0]] bb: let reworkedLine = [inputLine[0]] | |||||
Done Inline ActionsreworkedLine => entityDistribution bb: reworkedLine => entityDistribution | |||||
"type": "walk", | |||||
Done Inline ActionsdistanceBetweenEnts? bb: distanceBetweenEnts? | |||||
Done Inline ActionsThere are some edgy cases here still, f.e. allign the units on a line, and send them to a line orthagonal on the first, with one of the endpoints on an endpoint of the original line (So we turn the line 90deg), I would expect the unit on the endpoint of both lines to stay where it is, and swing the line over, However (lets assume that unit is the first on the first corner, argument is symmetrical) then firsttofirst < firsttoLast, but neither of the first conditions holds. bb: There are some edgy cases here still, f.e. allign the units on a line, and send them to a line… | |||||
Done Inline ActionsI think with your code they will walk a little bit longer. But how they are walkin looks better for die eyes ;) OptimusShepard: I think with your code they will walk a little bit longer. But how they are walkin looks better… | |||||
"entities": [selection[i]], | |||||
Done Inline ActionsIf you accidentally select a cc and drag the mouse when setting a rally point, you'll get:
Because if selection.length = 0, shouldDist is negative and the while loop on L1244 doesn't end. temple: If you accidentally select a cc and drag the mouse when setting a rally point, you'll get:
>… | |||||
Done Inline ActionsNow you need a minimum number of units OptimusShepard: Now you need a minimum number of units | |||||
Done Inline ActionsI think you want to use the reverse() method bb: I think you want to use the `reverse()` method | |||||
Done Inline Actionsthx OptimusShepard: thx | |||||
"x": entityDistribution[i].x, | |||||
Done Inline Actionsno space needed after - bb: no space needed after `-` | |||||
Done Inline Actionsinline bb: inline | |||||
"z": entityDistribution[i].y, | |||||
Done Inline Actionsreturn action && doAction elexis: `return action && doAction` | |||||
Done Inline Actionscould be a forEach bb: could be a forEach | |||||
"queued": false | |||||
Done Inline Actionsunneeded braces bb: unneeded braces | |||||
}); | |||||
} | |||||
} | |||||
else | |||||
Done Inline ActionsThis will spam the replay files. Not sure if there is a performance overhead attached too. elexis: This will spam the replay files. Not sure if there is a performance overhead attached too.
It… | |||||
Done Inline ActionsAlso I think the player would appreciate being able to use the modifiers, like attack-walk elexis: Also I think the player would appreciate being able to use the modifiers, like attack-walk | |||||
Done Inline Actions
What would be the usecase? Imarok: > Also I think the player would appreciate being able to use the modifiers, like attack-walk… | |||||
Done Inline ActionsI also don't see the usecase, but it doesn't hurt OptimusShepard: I also don't see the usecase, but it doesn't hurt | |||||
Done Inline Actions
seems ok Imarok: > This will spam the replay files. Not sure if there is a performance overhead attached too.
>… | |||||
{ | |||||
entityDistribution.sort((a, b) => b - a); | |||||
for (let i in entityDistribution) | |||||
Done Inline ActionsEngine.HotkeyIsPressed("session.queue") bb: Engine.HotkeyIsPressed("session.queue") | |||||
{ | |||||
Done Inline Actionsshouldn't we multiply with shouldDist? bb: shouldn't we multiply with `shouldDist`? | |||||
Done Inline Actionsno. its correct OptimusShepard: no. its correct | |||||
Done Inline Actionsyou are correct bb: you are correct | |||||
Engine.PostNetworkCommand({ | |||||
"type": "walk", | |||||
Done Inline ActionsCould use type: hotkey ? "walk-line" : "attack-walk-line" Shouldn't this support queueing too as usual? elexis: Could use `type`: hotkey ? "walk-line" : "attack-walk-line"
Shouldn't this support queueing… | |||||
Done Inline Actionsif queued is true, you can't react quickly OptimusShepard: if queued is true, you can't react quickly | |||||
"entities": [selection[i]], | |||||
"x": entityDistribution[i].x, | |||||
"z": entityDistribution[i].y, | |||||
"queued": false | |||||
}); | |||||
} | |||||
Done Inline Actions(Perhaps its nicer to use Vector functions here to avoid the duplication of the computation for the second axis. Performance likely no issue as this only occurs on button up. In fact it looks like x0 and z0 are exactly the coordinates of that vector 3 lines above. Also some of the vectors used in here (x1-z1) could be computed above the while loop) elexis: (Perhaps its nicer to use Vector functions here to avoid the duplication of the computation for… | |||||
Done Inline Actionswhat if there are two missing points? bb: what if there are two missing points? | |||||
} | |||||
} | |||||
Done Inline ActionsVector2D.sub(vector1, vector2) seemed nicer than clone.sub. normalize() instead of division by dist elexis: `Vector2D.sub(vector1, vector2)` seemed nicer than clone.sub. `normalize()` instead of division… | |||||
Done Inline Actionsfor of bb: for of | |||||
Done Inline Actionsdoesn't work OptimusShepard: doesn't work | |||||
} | |||||
return true; | |||||
} | |||||
Done Inline Actionsvec1.distanceTo(vec2) elexis: `vec1.distanceTo(vec2)` | |||||
Done Inline Actionsmy last coordinate is z, so it doesn't work OptimusShepard: my last coordinate is z, so it doesn't work | |||||
function handleMinimapEvent(target) | function handleMinimapEvent(target) | ||||
{ | { | ||||
// Partly duplicated from handleInputAfterGui(), but with the input being | // Partly duplicated from handleInputAfterGui(), but with the input being | ||||
Context not available. | |||||
Done Inline Actions+1 tab elexis: +1 tab | |||||
Done Inline Actions(comment redundant with the code) elexis: (comment redundant with the code) | |||||
Done Inline ActionsThat vector is created twice. Also doesn't the entity state have that vector already? elexis: That vector is created twice. Also doesn't the entity state have that vector already? | |||||
Done Inline ActionsWitch entity state vector do you mean? If I need x and z for a 2D vector, I can't take this vector? OptimusShepard: Witch entity state vector do you mean? If I need x and z for a 2D vector, I can't take this… | |||||
Done Inline ActionsIn that version new Vector2D(unit.position.x, unit.position.z) was repeated, but not anymore. elexis: In that version `new Vector2D(unit.position.x, unit.position.z)` was repeated, but not anymore. | |||||
Done Inline ActionsSome of this code looks duplicated. Could it be moved to a helper function? elexis: Some of this code looks duplicated. Could it be moved to a helper function? | |||||
Done Inline ActionsIs it possible to run the helper function in an own task for better performance? OptimusShepard: Is it possible to run the helper function in an own task for better performance? | |||||
Done Inline ActionsIf task = thread, then no. I mean it would be possible with adding lots of C++ code. Since this function is executed twice for all entities, can't this just be done once and cached? (I guess not because the reworkedline changes) elexis: If task = thread, then no. I mean it would be possible with adding lots of C++ code.
The… | |||||
Done Inline ActionsThis would be difficult. Selection changes. OptimusShepard: This would be difficult. Selection changes. | |||||
Done Inline ActionsThis looks broken (as in missing property names and spaces) elexis: This looks broken (as in missing property names and spaces) | |||||
Done Inline ActionsIt works. It could/should be correct. OptimusShepard: It works. It could/should be correct.
https://developer.mozilla.org/en… | |||||
Done Inline Actions== null is also true if == 0 if I'm not mistaken (see "falsey"). If you want that you can just use !minDist, otherwise === null elexis: `== null` is also true if `== 0` if I'm not mistaken (see "falsey"). If you want that you can… | |||||
Done Inline Actions(probably better from a performance point of view to use the pythagorean distance function from Math rather than creating an object that is used only once) elexis: (probably better from a performance point of view to use the pythagorean distance function from… | |||||
Done Inline Actions(looks like it could use for (let ent in selection), or for...of?) elexis: (looks like it could use `for (let ent in selection)`, or for...of?) | |||||
Done Inline Actionsif reworkedLine.length> selection.length we will fail here, maybe change it around and let every unit go to the closest free spot on the line bb: if reworkedLine.length> selection.length we will fail here, maybe change it around and let… | |||||
Done Inline ActionsI don't think that reworkedLine(entityDistribution) could mathematicaly get bigger than selection? OptimusShepard: I don't think that reworkedLine(entityDistribution) could mathematicaly get bigger than… | |||||
Done Inline Actionsbut you say that due to rounding errors is can get smaller, and rounding errors will go both ways, okay we need to round a whole lineResolution to get this bugged, which is very unlikely to happen, but if it bugs it will be a pain to fix, and it can easily be solved by some splice method bb: but you say that due to rounding errors is can get smaller, and rounding errors will go both… | |||||
Done Inline ActionsThx. I didn't see that problem. Now it should be save OptimusShepard: Thx. I didn't see that problem. Now it should be save | |||||
Done Inline Actionsmin => minimum bb: min => minimum | |||||
Done Inline Actionsinstead of passing reworkedLine and i it could be reworkedLine[i] bb: instead of passing `reworkedLine` and `i` it could be reworkedLine[i] |
The state should not be named according to the virtual key pressed, but to the consequential action.
So INPUT_UNIT_POSITION_START and INPUT_UNIT_POSITIONING maybe