Commit graph

90 commits

Author SHA1 Message Date
Dunedan
93ce94655d
Use @stylistic/brace-style for eslint
Up to now `eslint-plugin-brace-rules` was used to enforce a common brace
style for JavaScript code. This plugin was however updated the last time
over 9 years ago and will be incompatible with ESLint v10, as that
[removes `context.getSourceCode()`][1], the plugin relies on.

To keep the eslint config working with ESLint v10, this replaces
`eslint-plugin-brace-rules` with the [`@stylistic/brace-style`][2] rule
from `@stylistic/eslint-plugin`, a package we already use.

While `@stylistic/brace-style` doesn't offer an option to format braces
in exactly the same way as before, the "allman" style seems to be the
one closest to the existing code.

[1]: https://eslint.org/blog/2025/11/eslint-v10.0.0-alpha.0-released/#removed-deprecated-rule-context-members
[2]: https://eslint.style/rules/brace-style
2026-01-12 21:33:52 +01:00
Ralph Sennhauser
f29f0b7fd1
Enable eslint rule 'no-prototype-builtins'
Enable recommended rule 'no-prototype-builtins' [1] and manually fix violations.

[1] https://eslint.org/docs/latest/rules/no-prototype-builtins

Ref: #8068
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-17 13:47:11 +02:00
Ralph Sennhauser
97a82cbc4a
Enable eslint rule 'no-redeclare'
Enable recommended rule 'no-redeclare' [1] and manually fix violations.

[1] https://eslint.org/docs/latest/rules/no-redeclare

Ref: #8068
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-14 14:53:10 +02:00
Ralph Sennhauser
0ce889ca6d
Use stylistic for deprecated eslint rules
During the eslint 8 cycle the formatting rules were split out [1],
deprecating the corresponding rules in core.

This replaces all rules that where moved to @stylistic/eslint-plugin [2]
and accounts for the difference in the indenting rule behaviour.

To allow the pre-commit import hack to continue to work with the
stylisitc plugin for a recent nodejs version to be used.

[1] https://eslint.org/blog/2023/10/deprecating-formatting-rules/
[2] https://eslint.style/packages/default

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-10 21:23:23 +02:00
Ralph Sennhauser
f3ac9e9669
Fix eslint rule 'default-case'
Manual fixes needed for:
eslint --no-config-lookup --rule '"default-case": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-28 19:24:50 +02:00
Ralph Sennhauser
e7f1406c37
Fix eslint rule 'prefer-const' in components/[T-V]*
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/simulation/components/[T-V]*

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-12 13:12:45 +02:00
Ralph Sennhauser
81c119bf39
Fix eslint rule 'semi'
eslint --no-config-lookup --fix --rule '"semi": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 14:13:14 +02:00
Freagarach
0dcaefc2f6 Add error to TechMan. when trying to finish a non-existing technology (e.g. wrong allied_view tech defined).
This was SVN commit r27935.
2023-11-16 09:40:44 +00:00
Freagarach
9bb9ff8b16 Add Requirements helper.
Allows more flexibility in e.g. the Identity requirements and unifies
the checking of requirements.
One can use the script at https://code.wildfiregames.com/P265 to fix
templates.

Differential revision: https://code.wildfiregames.com/D4514
Comments by: @elexis, @Stan
Fixes #6421

This was SVN commit r27245.
2022-11-24 11:20:11 +00:00
Freagarach
ea72437739 Move GenericName, History and Icon from the civ-JSON to cmpIdentity.
Since the players/civs already have cmpIdentity, use it.
This forces civs to have corresponding XML in the `special/players/`
folder.

Also moves the files from `special/player/` to `special/players/`
consistent with other folders. And moves the generic `player.xml` one
level up.

Differential revision: https://code.wildfiregames.com/D4473
Help and comments by: @Stan, @wraitii
This was SVN commit r26298.
2022-02-05 06:24:45 +00:00
Freagarach
73f741d266 Handle researching technologies in the TechnologyManager.
Moves the work done from cmpResearcher to cmpTechnologyManager.
No functional changes.

It allows fancy stuff in the future (#6364).

Differential revision: https://code.wildfiregames.com/D4438
This was SVN commit r26252.
2022-01-26 07:42:36 +00:00
Freagarach
0c4f59d0a7 Split tasks from ProductionQueue.
The task of the production queue should first and foremost be that; a
queue for production items.
Hence, the specifics of training/researching are delegated to specific
components.

As a side effect, this improves the test coverage and fixes:
- Resource not refunding when hitting the entity limit. Introduced in
b8758c8941.
- Autoqueue changing when unable to spawn. Introduced in 956b3f96db.

Modders can change their templates using
https://code.wildfiregames.com/P256.

Differential revision: https://code.wildfiregames.com/D4333
Fixes: #6363
Comments by: @Silier
Refs. #6364

This was SVN commit r26000.
2021-11-16 07:08:39 +00:00
Freagarach
c3da0cdd0f Fix cosmetic ESLint warnings in JS components (and their tests).
Which were autofixable, with slight modifications.
Not done are the slightly more complex changes.

Refs. #5524
Patch by: @Krinkle
Differential revision: D2279
Comments by: @elexis, @Stan
Reviewed by: @wraitii
This was SVN commit r25087.
2021-03-20 09:02:22 +00:00
bb
0a26c55513 Fix more JsDocs numbers/bools/strings
This was SVN commit r23992.
2020-08-24 11:50:31 +00:00
bb
3ff65b451f Fix jsDocs object => Object
This was SVN commit r23991.
2020-08-24 11:01:25 +00:00
Angen
c47496cf18 Cleanup ResearchTechnology function
Remove unused variable since e16c4c4800 and call for ranged manager.
Transform comment to javadoc.
var -> let

Differential Revision: https://code.wildfiregames.com/D2631
Patch by: Freagarach
Reviewed by: Angen
This was SVN commit r23587.
2020-04-15 21:26:25 +00:00
wraitii
db4fabcc4c Fix phase notification accidentally deleted in e16c4c4800
Reported By: elexis
Tested By: Freagarach
Differential Revision: https://code.wildfiregames.com/D2336
This was SVN commit r23014.
2019-09-29 08:53:28 +00:00
wraitii
db4637f73a Fix issue with D274/e16c4c4800 - modifications are a list of effects, not a single effect
D274 introduced a silent change that modifications would only have one
effect per value-path, which was an unnoticed regression.

Detected following the comments from SonarQube reported here:
e16c4c4800#inline-4214

Comments By: elexis
Differential Revision: https://code.wildfiregames.com/D2315
This was SVN commit r22967.
2019-09-22 12:05:04 +00:00
wraitii
e16c4c4800 Add a system component to handle stat modifiers, make technologies and auras use this common interface.
The ModifiersManager system component provides an interface to add and
remove modifiers, and get modified stats.
The goal is to merge all the different stat-modifying systems 0 A.D. has
implemented over the years.
This commit makes technologies and auras use ModifiersManager. Some
cheats and AI bonuses also have a similar stat-modifying effect that
have not yet been updated.

Further, this system component makes it possible for e.g. triggers to
easily add modifiers, enabling the writing of Castle Blood Automatic,
RPG or Tower Defense maps without the need for mods or hacks.

The 'Modifier' name was preferred over 'Modification' as it is shorter
and more readable, along with the logic that 'modifiers' store
'modifications' and this stores modifiers. Renaming of other functions
and classes has been left for future work for now.

Internally, this uses a JS data structure. If performance issues arise
with it in the future, this data structure or the whole component could
be moved to C++.
The performance has been tested to be about as fast as the current
implementations (and specifically much faster for global auras with no
icons). Testing showed that sending value modification messages was by
far the slowest part.

Comments by: leper, Stan, elexis
Differential Revision: https://code.wildfiregames.com/D274
This was SVN commit r22767.
2019-08-24 07:37:07 +00:00
bb
3a77eb25d3 Fix ESLint semicolon-related warnings
Patch By: Krinkle
Differential Revision: https://code.wildfiregames.com/D2004
This was SVN commit r22419.
2019-07-01 11:09:19 +00:00
wraitii
f4babd9b34 Wrap damage types in a Damage element in XML templates to prepare for genericizing them.
Patch By: Freagarach
Reviewed By: Wraitii
Differential Revision: https://code.wildfiregames.com/D1950
This was SVN commit r22379.
2019-06-16 17:08:27 +00:00
elexis
d5af005a00 Expose INVALID_PLAYER to the JS simulation and use it instead of -1 for consistency with the C++ counterpart.
This was SVN commit r20953.
2018-01-22 01:02:29 +00:00
bb
c9295a0f59 Nuke missleading non-existing spearman/sword(s)man classname references.
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1173
This was SVN commit r20746.
2018-01-01 15:06:52 +00:00
elexis
c90d72deb5 Replace DataTemplateManager simulation component with a globalscript, refs #4868.
Removes the serialization of JSON files, shrinking savegame files and
rejoin states sent across the network, refs #3834, #4239, #3909,
f24523dc8f.
Removes the AI C++ code to read JSON files from e33d4a52e9 since the AI
can now use the globalscript.
Allows the AI to read Aura templates and removal of GUIInterface code to
improve performance.
Serialization of the JSON objects in other simulation components was
removed in 9c0e37f2c0 / D1109, a6f14f5631 / D1130.

Serialization removal planned by sanderd17
AI part proofread by mimo
Simulation part proofread by bb
Discussed with Itms on irc

Differential Revision: https://code.wildfiregames.com/D1108
This was SVN commit r20737.
2017-12-31 01:02:21 +00:00
elexis
2fd163a08a Remove TechnologyManager relict of 99d04e93bb following c1e86161b5.
This was SVN commit r20616.
2017-12-08 23:11:00 +00:00
elexis
5667de04c8 Use Map instead of Object in researchQueued of the TechnologyManager for code symmetry with the two previous commits, a6f14f5631 and dc72833040.
Comments in https://code.wildfiregames.com/D1130

This was SVN commit r20612.
2017-12-08 19:29:10 +00:00
elexis
dc72833040 Use Set instead of an Object with unused values in TechnologyManager.researchStarted.
Differential Revision: https://code.wildfiregames.com/D1129
Reviewed By: mimo
This was SVN commit r20611.
2017-12-08 18:47:07 +00:00
elexis
a6f14f5631 Remove unused serialized cache of technology templates in TechnologyManager.researchedTechs.
Refs #3834, #3909, #4239, #4868, D1108
Differential Revision: https://code.wildfiregames.com/D1130
Reviewed By: mimo
This was SVN commit r20610.
2017-12-08 18:35:04 +00:00
elexis
9c0e37f2c0 Don't serialize the templates of autoresearched technologies.
Refs #3834, #4239
Differential Revision: https://code.wildfiregames.com/D1109
Reviewed By: temple
Comments By: Itms
Proposed By: sanderd17
This was SVN commit r20606.
2017-12-07 23:26:29 +00:00
mimo
8a32deb5ca Fix tutorial stuck after building farm
Trac Tickets: #4696, #4697

Differential Revision: https://code.wildfiregames.com/D774
This was SVN commit r19998.
2017-08-19 09:38:52 +00:00
fatherbushido
f83897d4b2 Fix an issue with technology modifications. Modifications for the player entity were handle by auras but not by technologies. Reviewed by mimo.
Differential Revision: https://code.wildfiregames.com/D504
This was SVN commit r19637.
2017-05-22 05:21:40 +00:00
elexis
ec58e50a09 Remove a duplicate TechnologyManager getter introduced by e33d4a52e9.
Differential Revision: https://code.wildfiregames.com/D373
Patch By: Polakrity
This was SVN commit r19446.
2017-04-23 00:30:24 +00:00
elexis
51d189c767 Display a chat notification if an ally has reached a new phase, optionally also if started or aborted.
Remove the equivalent AI chat notifications.

Differential Revision: https://code.wildfiregames.com/D354
Patch By: Polakrity
Fixes #3512

This was SVN commit r19445.
2017-04-23 00:00:14 +00:00
wraitii
d15b35357e Show effects of game-start tech modifications in Structure Tree.
This also refactors code so that external callers will have an easier
time getting a template value as modified by technologies.

Patch by s0600204.

Reviewed by bb and wraitii.
Differential Revision: https://code.wildfiregames.com/D154
This was SVN commit r19410.
2017-04-11 14:36:30 +00:00
fatherbushido
9cf84c6800 Fix documentation of non system component.
Summary: -

Test Plan: -

Reviewers: Itms, leper

Reviewed By: leper
Subscribers: Vulcan, O1 C++ Simulation

Differential Revision: https://code.wildfiregames.com/D221
This was SVN commit r19337.
2017-03-24 07:09:28 +00:00
elexis
ad17e320be Rename the Female identity class to FemaleCitizen, because it is intended for female support units only.
Thus prevent template editors from adding that tag to female military
units and
allow modders to add a Female class for wider purposes.
Remove the FemaleCitizen training restriction category that was added
for debug purposes but forgotton to be removed in 7e21db08d5.

Differential Revision: https://code.wildfiregames.com/D244
Reviewed By: fatherbushido
Refs: #1432 #4490

This was SVN commit r19329.
2017-03-23 17:54:36 +00:00
mimo
2e636af9bc fix missing semicolons
This was SVN commit r19126.
2017-01-09 19:03:24 +00:00
fatherbushido
6c97d8118b Merge different logics of technology requirements and fix the related bugs. Create a global script which derive the technology requirements objects in a form usable for structure tree, gui, simulation and AI. Reviewed by mimo (for AI) and fatherbushido. Fixes #3993, #1646, #4263, #4217. Refs #4108.
This was SVN commit r19120.
2017-01-08 14:00:20 +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
25e637dcac Fix issue with undefined newValue while origValue is defined.
This was SVN commit r18262.
2016-05-29 18:10:57 +00:00
sanderd17
9368ffe345 Fix tech modifications calculations so we don't bump into stupid mistakes again (f.e. multiplying two positive numbers is now guaranteed to stay positive). See 7f300bbf3d and 0b8845eb4f
This was SVN commit r18207.
2016-05-20 11:20:51 +00:00
sanderd17
f24523dc8f Rename TechnologyTemplateManager to DataTemplateManager in order to reflect its new function. Fixes #3909. Disable serialisation of technology templates. Refs #3834
This was SVN commit r18100.
2016-04-27 08:25:47 +00:00
sanderd17
a69da3401f Completely hide techs that aren't researchable by the civ of the owner + cleanup of requirements checking. Patch by fatherbushido. Fixes #3899
This was SVN commit r18027.
2016-04-13 09:15:16 +00:00
sanderd17
e0cfcbd806 Enable technologies on captured buildings. Allow a negation on the civ selection in the technology json files. Patch by fatherbushido
This was SVN commit r18021.
2016-04-11 19:40:53 +00:00
mimo
a7743e95b9 cleanup of unused counters
This was SVN commit r17605.
2016-01-06 21:15:58 +00:00
mimo
0b86bbd424 another bunch of cleanup (mainly missing semicolon) signaled by jshint
This was SVN commit r17045.
2015-09-19 12:50:48 +00:00
mimo
00a51404c9 cleanup of some for ... in loops on arrays (replaced by for ... of)
This was SVN commit r16996.
2015-09-09 18:21:17 +00:00
sanderd17
cc4af6d2d4 Allies only share vision when researching a tech. Based on patch by niektb. Fixes #2055
This was SVN commit r16795.
2015-06-19 09:24:55 +00:00
mimo
4a7994a595 improve indentation in previous tag
This was SVN commit r16724.
2015-06-04 21:26:01 +00:00
mimo
f1f8479ffe fix entityLimits with replaced tech
This was SVN commit r16723.
2015-06-04 21:24:34 +00:00