Commit graph

25 commits

Author SHA1 Message Date
Ralph Sennhauser
4e5cdc87b9
Fix eslint rule 'spaced-comment'
Manual fixes needed for:
eslint --no-config-lookup --rule '"spaced-comment": ["warn", "always"]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-17 12:08:47 +02:00
Ralph Sennhauser
0791504491
Fix eslint rule 'prefer-const' in globalscripts
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/globalscripts

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-06 14:16:42 +02:00
vladislavbelov
a8f241da5d Adds snapping to edges for buildings
Allows to place buildings a bit faster and more perfectly aligned. Also
it helps to find a nearest placeable position in some cases.

Reviewed By: elexis
Comments By: Stan, wraitii
Differential Revision: https://code.wildfiregames.com/D2079
This was SVN commit r23330.
2020-01-05 01:08:05 +00:00
elexis
65b02395b3 Remove Vector2D/Vector3D prototype workaround from EngineScriptConversions.
Fixes #5376, refs #2394.
Differential Revision: https://code.wildfiregames.com/D1991
Patch By: Krinkle
Comments By: Vladislav, wraitii
This was SVN commit r22487.
2019-07-16 21:52:49 +00:00
bb
a1ddf6114a Allow units to be positioned with freehand placement
Patch By: OptimusShepard
Comments By and Agreed With: elexis
Comments By: Imarok
Differential Revision: D1021
fixes #4791

This was SVN commit r21378.
2018-02-25 22:17:19 +00:00
elexis
f63cc9a1d2 Static Vector2D min and max.
This was SVN commit r21129.
2018-02-06 22:52:53 +00:00
elexis
23820c5713 Static equality test for vectors.
This was SVN commit r21106.
2018-02-02 20:13:31 +00:00
elexis
30fe33bb0b Add another Vector2D rotation test (illustrating the most common rmgen rotation transformation).
TS_ASSERT_EQUALS_APPROX must not silently pass if epsilon wasn't given.
Sort Vector2D.rotate summands by component rather than saving one
character.

This was SVN commit r21062.
2018-01-29 09:51:20 +00:00
elexis
de3c50adf0 Floor operation on vectors.
Useful to get the coordinates of a tile of an entity position for
instance.

This was SVN commit r21024.
2018-01-27 01:38:23 +00:00
elexis
fd08061ab6 Allow Vectors to be rounded.
For instance useful when working with location vectors on arrays, such
as terrain generation in random map scripts, refs #4845.

This was SVN commit r20723.
2017-12-29 15:37:16 +00:00
elexis
774a049cdd Vector cleanup.
Improve some of the comments mentioned by fatherbushido in b3dbcc457b.
Rename avg to average and test it.
Inline constructor defaults.
Don't use array functions nor for...of loops here to maximize the
performance, refs c751500907.

This was SVN commit r20706.
2017-12-28 01:54:56 +00:00
elexis
8ee2a8aca2 Add Vector2D angleTo and Vector3D horizAngleTo function.
Use it to illustrate the building placement preview rotation and
focusing of attacked units.

Split from D1037
Patch By: temple
This was SVN commit r20496.
2017-11-21 16:17:30 +00:00
elexis
eb96b61954 Add rotateAround Vector2D function.
Remove the rmgen rotateCoordinates helper function from 4256744e26 and
clean the implementation of that commit, refs #4845, #4804.
Deepfreeze mapCenter vector from 5256d8497e used here to prevent
accidental overwrites with the mutating Vector2D functions, refs #4854.

This was SVN commit r20468.
2017-11-17 00:10:29 +00:00
elexis
a2f7dba96c Move simulation test for approximate equality from e18598cd62 to the test setup, so that it can be reused.
Remove unneeded helper variable from e18598cd62 as intended by
7778a7b436 by using the set method.

This was SVN commit r20467.
2017-11-16 23:54:38 +00:00
elexis
db1d94bad0 Further clarify geometric meaning of the river painting in a9b963c3a5 and e596ef6011.
Refer to the normalized river vector instead of the river vector divided
by the length of the river.
Rename mag to magnitude.

This was SVN commit r20435.
2017-11-10 17:17:59 +00:00
elexis
b3dbcc457b Add Vector3D crossproduct and Vector2D perpendicular function.
Describe geometric features of the two cross- and dot-product functions.

This was SVN commit r20428.
2017-11-09 19:04:39 +00:00
elexis
6590f301c2 Add Math.square to compute the square of a number without the need to repeat the term, without using the slower Math.pow.
Start unifying the euclidian distance functions instead of adding yet
another helper function to the random map script library after this
diff.

Differential Revision: https://code.wildfiregames.com/D969
Math.square accepted by mimo
Includes changes proposed by bb, fatherbushido

This was SVN commit r20328.
2017-10-22 20:46:41 +00:00
elexis
e18598cd62 Fix Vector.js rotate oversight in 7778a7b436 (this.x may not be modified before reading again and sin/cos should not be computed twice).
Extend the tests of rotate in 99494251a1 to reveal the bug.
Add non-static clone functions for vectors (as the static ones were
incorrectly removed in e95f4e9744).
Math.pow performance is investigated separately, refs P85.

Checks and balances by mimo, leper, FeXoR and fatherbushido

This was SVN commit r20272.
2017-10-08 15:25:21 +00:00
elexis
7778a7b436 Readability improvements of globalscripts vector.js.
In compareLength, use Math.sign to replace a ternary + isNaN check.
In distanceToSquared, Use Math.pow(distance, 2) to avoid repetition of
the distance, inline its value to remove the then unneeded variables.

This was SVN commit r20263.
2017-10-06 18:20:57 +00:00
elexis
e95f4e9744 Unify deepcopy and clone.
Delete clone globalscripts function introduced by 9f47ed536d.
Rename the better supported deepcopy function to clone.
Delete unused Vector2D and Vector3D clone prototype functions that can
just use clone if needed.

Differential Revision: https://code.wildfiregames.com/D870
Reviewed By: leper
This was SVN commit r20125.
2017-09-06 20:58:27 +00:00
mimo
f01e932ce3 fixes a few missing semicolon
This was SVN commit r19025.
2016-12-07 18:06:12 +00:00
elexis
6149dd3841 Actually remove trailing whitespace for non-header files as well.
This was SVN commit r18989.
2016-11-23 13:02:58 +00:00
sanderd17
c751500907 Refactor some formation code to let it make use of the prototypes
This was SVN commit r14693.
2014-01-27 12:34:59 +00:00
sanderd17
ecaded076f Improve the Vector prototype with static functions. Replace the usage of the Math vector functions with functions from the Vector class.
This was SVN commit r14659.
2014-01-24 19:51:00 +00:00
sanderd17
fd187f466f Add vector prototype to vector-like return values from C++ to JS. Fixes #2394.
This was SVN commit r14645.
2014-01-23 11:32:08 +00:00