1
0
forked from 0ad/0ad
Commit Graph

21693 Commits

Author SHA1 Message Date
87fc52b780 MP: don't enforce game init attributes synchronization in PREGAME.
The NetServer stored a complete copy of the game Init Attributes, which
it sent to new clients on updates from the controller. This worked well,
but prevents incremental updates and other unrelated messages from being
sent.

This changes the system so that:
- in PREGAME state, the server does not update its copy of the game init
attributes
- the server forwards game setup messages from the controller to all
clients
- Joining clients get a full copy of the Settings, when joining, from
the controller (this is a js-driven behaviour - other situations might
not need do it).
- Make the StartNetworkGame message take a copy of the final init
attributes, to ensure synchronization (and simplify some logic).

In practice, this:
- makes it possible to send different types of gamesetup messages (this
introduces two: a regular update and the full 'initial-update' for new
clients).
- moves some C++ hardcoding into JS - here in essence the PREGAME server
state is now init-attributes-agnostic.
- does not change much for readiness control - the server already needed
to force a change at game start to set random elements.

Note that the loading page is currently still receiving the 'local' game
attributes, which assumes that all clients are correctly synchronized
(they should be).

Refs #3806, #3049

Differential Revision: https://code.wildfiregames.com/D3714
This was SVN commit r25099.
2021-03-22 10:13:27 +00:00
8c2ab4df62 Improve & translate hotkey name/descriptions.
Improve the hotkey translations. This adds them to messages.json for
translation, closing the work from 09ad8bfbe5

Refs #5867, refs #5996

Differential Revision: https://code.wildfiregames.com/D3641
This was SVN commit r25097.
2021-03-21 14:23:57 +00:00
fa3b341b57 Further gamesetup fixes & tweaks.
Fixes dc18d94030

- Player assignment still had some trouble. This cleans things up by
moving a little more logic in the controller & fixing other usage.
 - As a consequence, in MP, if the host swaps two player, the change
will take a few frames to register. It shouldn't be too much of a
problem in practice.
 - Fix issues with AI being assigned to player slots for joiners.
- Fix issues with similar color not being correctly picked when swapping
a map.
- Fix issues with rating & locked team settings.

Reported by: langbart
Differential Revision: https://code.wildfiregames.com/D3723
This was SVN commit r25096.
2021-03-21 13:09:52 +00:00
Angen
841bf5f2dd Color incompatible mods and add filter
This helps to see compatible mods in the list, which can get a bit long.
For incompatible mods in disabled section use gray colour.
For incompatible mods in enabled section use red colour (what can happen
when using arguments to start the game or they can be in config file).
Add option to filter compatible mods, this does not affect enabled
section, because if there is incompatible mod, it is error and it needs
to be always visible.
Add function recomputeCompatibility and g_ModsCompatibility to avoid
recomputing aredependenciesmet when coloring mods, because every column
is colored separately.
Disable enable mod button if mod is incompatible.
Remove all dependencies met messages as they are now replaced by this
mechanism.

fix getSelectedModUrl in process

Differential revision: D3687
Fixes: #6053
Tested by: @Freagarach
Comments by: @vladislavbelov
This was SVN commit r25095.
2021-03-21 10:22:50 +00:00
Angen
1c68d9890b Remove redundant applyFilters method from modmod
All functionality in applyFilters is handled by displayModLists and
modSelected functions.
This is also fixing issue of triggering selected event on the same list
multiple times and not updating mod description and buttons when
applying filters.

Differential revision: D3722
This was SVN commit r25094.
2021-03-21 08:51:17 +00:00
Angen
84bafd82b1 common-api entity.js cleanup
Do not check for undefined when result is returning undefined or the
variable and nothing else is done.
Dont create variables when might not be used or are returned without
other usage after.
Dont call get with same parameter more than necessary.

Differential revision: D3652
Comments by: @Freagarach
This was SVN commit r25093.
2021-03-21 08:49:26 +00:00
aa9292b1fc Fix fishing boats hunting whale.
Accidentally introduced in 24f0cc7695.

Fixes: #6110
Patch by: @Langbart
Differential revision: D3716
Reviewed by: @Nescio
This was SVN commit r25092.
2021-03-20 20:08:48 +00:00
7b00d93298 Fix MP Player assignment
Players could not be assigned beyond the first N slots.

Reported by: langbart
Differential Revision: https://code.wildfiregames.com/D3721
This was SVN commit r25091.
2021-03-20 18:04:22 +00:00
07908dfd8c Store components to be miraged in cmpFogging.
Allows modders (and us) to just add an IID to the array and ensure the
`Mirage()`-function to exist in the respective component.

Differential revision: D3713
Comment by: @wraitii
This was SVN commit r25090.
2021-03-20 16:14:35 +00:00
a4a7ef983e Move Mirage information to respective components.
Moves the functions that define the properties/functions to mirage to
their respective components, making it easier for modders to know their
existence and to modify.

Closes: #5985
Differential revision: D3695
Comments by: @wraitii
This was SVN commit r25089.
2021-03-20 16:01:11 +00:00
dd74837e6e Convert InitAttributes disabled techs/templates & starting tech to triggers.
Disabled technologies & templates are not really gamesetting concerns,
since they are map-specific and de-activating these generally does not
make sense.
Starting technologies is unused and not the correct granularity level
for game setup.

Triggers do a better job of specifying these things on a per-map basis
(in fact, some maps already use triggers for that).

Changes:
- StartingTechnologies was used by the cart sandbox and is simply
removed.
- DisabledTechnologies was used by Polar Sea RM, which already had
triggers -> into triggers.
- DisabledTemplates was used for the Ptol Lighthouse on a few maps ->
since we changed the ability to "a lot of range", it's no longer OP on
these maps and the restriction is simply lifted.
- DisabledTemplates was used on Death Canyon Invasion Force -> into
triggers.

Differential Revision: https://code.wildfiregames.com/D3712
This was SVN commit r25088.
2021-03-20 09:36:56 +00:00
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
c4d5729c73 Adds basic tests for BuildCameraRay and uses viewport instead of renderer for width and height.
This was SVN commit r25085.
2021-03-19 17:39:34 +00:00
30432574fa Fix issues with dc18d94030
Issues from dc18d94030 fixed:
- The AI config page does not work
- Player Color/Civ/Team did not reset when switching out of Scenario,
which locked the setting
- Player color had weird issues with resetting when changing map too.
- Pop Cap could not be changed.
- Explored/Revealed were swapped in the game description (this was
actually fixed at some point in the original diff then reverted).

Reported by: Submariner and langbart

Differential Revision: https://code.wildfiregames.com/D3715
This was SVN commit r25084.
2021-03-19 16:41:17 +00:00
76c5263607 Rename GameAttributes to InitAttributes
The initial settings for a game, used to create the map in RM & tosetup
the simulation, are named InitAttributes in the C++, but generally
referred to as GameAttributes in the JS GUI. This renames the latter to
the former to avoid confusion, since these settings are immutable once
the map starts, so InitAttributes is more accurate.

Differential Revision: https://code.wildfiregames.com/D3705
This was SVN commit r25083.
2021-03-19 10:02:10 +00:00
d751927b89 Linter fix on CI.
The CI wasn't properly reporting linting, as it turns out the output of
`arc lint --output json` is not what the Jenkins plugin expects.

This adds a custom lint printer that is compatible with the plugin
expectations.

Also delete the coala/ folder forgotten in the original diff.

Differential Revision: https://code.wildfiregames.com/D3709
This was SVN commit r25082.
2021-03-19 09:13:00 +00:00
ce0fb7770c Clean mirage internals.
Redo 9f27f0eed8. Now! with not broken serialisation :D

Use a map that stores the functions, instead of them being part of the
Mirage component.
Doesn't need to initialise the variables anymore (refs. #5979).

Saves the mirages in a global to allow (de)serialisation.
Only assign values on Init, not on Construction (to allow
deserialisation).

Refs: #5985
Differential revision: D3702
Comments by: @wraitii
This was SVN commit r25079.
2021-03-18 17:34:53 +00:00
961ac314ad Fix issues with motionManager / bae258f9a1
Fixes bae258f9a1.

As reported by Freagarach, garrisoned units trigger error messages.
As reported by Vladislavbelov, noPCH was broken & there were some style
issues.


Differential Revision: https://code.wildfiregames.com/D3707
This was SVN commit r25078.
2021-03-18 16:40:34 +00:00
dc18d94030 Separate Game Settings from the GUI Gamesetup
Split the gamesetup in two: the 'GameAttributes' part into gamesettings/
and the GUI/Presentation part in gamesetup/. This makes it easier to
separate the presentation from the data.

The immediate benefit is that campaigns & autostart scripts don't need
to load the gamesetup folder at all. This also makes it much easier for
any modder that would want to to change the GameSetup itself.

Each 'game attribute' is given a unique class extending GameSetting
(with a few exceptions), in charge of:
- 'Serializing' to the JSON-compatible 'InitAttributes' format, which is
used for persisted settings, network synchronization, map script
settings, hotloading.
- Deserializing from the same format.
- Watching for settings it depends on (such that e.g. unexploring the
map also unreveals it).

The GUI controls remain in charge of presenting the state accurately,
however they now directly subscribe to changes of the GameSettings for
update. The updating logic in general has been lightened on the GUI
side, making it more straightforward to know when something will update,
and reducing un-necessary computations (in theory - in practice, I
believe the gamesetup was already fairly good about this).
The 'Controller' class of the gamesetup have also been lightened, since
more responsibility now lies with GameSettings. In particular, this
include code to actually launch a game.

In general the GameSettings class is permissive - the GUI gamesetup has
tighter restriction for what the player can/cannot modify. This is
intended to give flexibility for campaign maps, which may want to change
arbitrary settings.

Further work would be useful, non-exhaustively:
- the setting of default values remains messy. They currently exist
somethings in GameSettings, sometimes in the GUI gamesetup, and in the
simulation itself (in case attributes are not set).
- the availability and 'lockedness' of settings remains a
work-in-progress.
- some attributes, like disabled technologies, should probably be
removed and triggers used instead.
- the Handling of AI and player-specific data could be improved.
- settings Persistence should follow its own path - not all settings are
worth persisting.
- GAIA settings are added simulation-side but not in the GUI, which is
confusing.

Thanks langbart & Freagarach for testing.

Follows the gamesetup rewrite in 34138a7764.

Refs #3049

Differential Revision: https://code.wildfiregames.com/D3243
This was SVN commit r25077.
2021-03-18 13:59:53 +00:00
413315024d Revert cleaning the mirage internals.
Broke serialisation.
Reverts 9f27f0eed8. (9f27f0eed8)

Refs. #5985
Differential revision: D3701
This was SVN commit r25076.
2021-03-18 09:42:15 +00:00
446c134feb Fix infinite loop in healing & potential one elsewhere.
HEAL can infinite loop: if the HEAL.APPROACHING:MoveTo call fails, the
unit will fallback to FINDINGNEWTARGET, which looks for new targets to
heal, which can loop around.
In #6106, the cause was that the target was not visible despite the
order being given (presumably a rangemanager/los incompatibility issue).
When MoveTo() fail, orders usually call FinishOrder as that's
irrecoverable.

Further, GATHERING/COLLECTINGTREASURE also did not FinishOrder - there,
we do want to consider new resources if the target is e.g. unreachable,
so add an explicit check for AbleToMove.

Reported by: moiman
Reviewed By: Freagarach
Fixes #6106

Differential Revision: https://code.wildfiregames.com/D3689
This was SVN commit r25075.
2021-03-18 09:01:19 +00:00
92f94e25c6 Adds ortho projection type and its test.
This was SVN commit r25073.
2021-03-17 23:03:35 +00:00
e7612e8fed Update UnitMotion comment following d4c2cf4430
MP turns are now identical in length to SP turns.

This was SVN commit r25072.
2021-03-17 18:04:31 +00:00
bae258f9a1 Implement a Motion Manager around UnitMotion.
This new MotionManager handles movement for UnitMotion components (not
UnitMotionFlying).
This is a first step towards unit pushing, by giving a central place for
the relevant units to collide.

One important side-effect is that movement is effectively synchronous -
the positions are not actually updated until all units have moved for a
turn (refs 6a66fb8205).

As a side-effect, it's an optimisation: fewer messages are being sent
overall, which leads to a slight speedup (negligible without a lot of
units though).

This is a first step - ideally, the movement functions called from
UnitMotionManager would actually be moved there.

Differential Revision: https://code.wildfiregames.com/D3509
This was SVN commit r25071.
2021-03-17 17:04:51 +00:00
ae07dcb4ff Removes joystick from camera controller.
Differential Revision: https://code.wildfiregames.com/D3700
This was SVN commit r25070.
2021-03-17 16:28:48 +00:00
8cdfc107b7 Let garrisoned entities be IDLE.
The "GARRISONED"-state was quite strange, for entities being garrisoned
can just as well perform other tasks (see e.g. turrets).
Also, the need for keeping a "garrison" order on the stack is removed.

Fixes: #6022
Differential revision: D3656
Refs. #6081

This was SVN commit r25069.
2021-03-17 14:53:09 +00:00
9f27f0eed8 Clean mirage internals.
Use a map that stores the functions instead of them being part of the
Mirage component.
Means that a lot doesn't need to be inited now (refs. #5979).

Ticket: #5985
Differential revision: D3694
Comments by: @wraitii
This was SVN commit r25068.
2021-03-17 14:42:06 +00:00
bc66700e11 Adds more detailed test for perspective camera projection and its corners in world space.
Cleanups CVector3D a little bit.

This was SVN commit r25066.
2021-03-16 22:42:29 +00:00
b989a6dc8f Minor improvements to campaigns support.
- Remove LevelID harcoding
- Forward the initial data to the endgame script.
- Update the currentRun logic to make it behave more expectedly.

Differential Revision: https://code.wildfiregames.com/D3649
This was SVN commit r25065.
2021-03-16 14:48:12 +00:00
a72423d3dc Clean up SpawnUnits in ProductionQueue.
Have an entity cache per item (refs. #6104) (which means it doesn't need
to be created at init; refs. #5979).
Cache the PQ-position instead of querying it for every spawned entity.
One could use any arbitrary player for spawning entities now, increasing
mod support.

Differential revision: D3669
Comment by: @wraitii
This was SVN commit r25064.
2021-03-16 06:01:23 +00:00
df45f538df Clean up AddBatch (AddItem) in ProductionQueue.
Removes indentation.
Adds return value.
Cache owner instead of querying often.

This function can be cleaned even more later.

Differential revision: D3670
Comments by: @wraitii
This was SVN commit r25063.
2021-03-16 05:55:04 +00:00
93fe2ffa8a Handle aura and production pause on GarrisonedStateChanged message.
This reduces hard-coupling between the components.

Refs. #6081
Differential revision: D3683
Reviewed by: @wraitii
This was SVN commit r25062.
2021-03-16 05:49:36 +00:00
5cbbd570c0 Add range overlay to artillery.
Structures have them since ad1ab0c3d3, but units were excluded there due
to their mobility and amounts.
Artillery is not that easily massed and also not very mobile, but has a
high range and damage with a low reload time, making it nice to know
their approximate range.

Patch by: @Nescio
Differential revision: D3606
Comments by: @Angen, @borg-, @wraitii
This was SVN commit r25061.
2021-03-16 05:35:19 +00:00
54fc516679 Fix rebase error in 8e34371deb
Reported by: Nescio
This was SVN commit r25060.
2021-03-15 18:53:35 +00:00
9db72570c2 Disable wicker baskets on polar sea.
There is no fruit on the map, therefore much like wood techs, the fruit
tech is disabled.

Patch by: Nescio
Differential Revision: https://code.wildfiregames.com/D3595
This was SVN commit r25059.
2021-03-15 15:52:32 +00:00
8e34371deb Streamline ship stats.
- Fishing boat build time from 20 to 15 (5 less than bireme/merchant).
- Quinquereme population from 3 to 5 (biremes have 2, triremes 3)
- Warships get a 2:1 wood to metal cost
- Loot is standardized to 20% of costs, XP to 10% of health, similar to
siege engines and structures.
- Fishing boath & Merchant ship have the same resistance as warships but
accordingly lower HP, for easier stat comparison.

Patch by: Nescio
Accepted By: borg-, wraitii
Differential Revision: https://code.wildfiregames.com/D2956
This was SVN commit r25058.
2021-03-15 15:45:20 +00:00
f05235ec09 Lower cavalry melee attack range again.
D3482/5701ffccf8 raised the melee attack range to 6 to compensate for
movement over a turn with 500ms MP turns.
Following D3275/d4c2cf4430, this is no longer necessary. Revert to 4
(half the footprint length + 1 & their capture range).

Patch by: Nescio
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D3673
This was SVN commit r25057.
2021-03-15 15:38:41 +00:00
c9f37fc613 Lint update: use arclint, remove JSHint, remove coala on CI.
This runs linting using the "arc lint" command of arcanist, which
notably gets run automatically as part of the arc diff workflow.

Changes:
- The major change is that arc lint reports, by default, only issues on
changed lines instead of changed files (--lintall changes that).
- JSHint is largely redundant with eslint and does not support some of
the new Javascript functionality that we are able to use in 0 A.D., such
as conditional chaining, thus it is removed (of course, users can still
run it manually).
- Eslint 7 is supported out of the box and updated to ES 2020
- cppcheck and eslint are optional - if the executable is not found
(e.g. in PATH), it will fallback to a 'dummy' PHP script that does
nothing. This has been tested on windows, mac and Debian (CI).
- The licence year linter now suggests replacement, and has been
rewritten as an arcanist linter.
- Add a JSON error linter.

The intention is to have non-intrusive external linting, and largely the
same text linting.

Coala has largely gone unmaintained in the past few years (more so than
arcanist anyways) and installing it on modern Python is convoluted.

Differential Revision: https://code.wildfiregames.com/D3639
This was SVN commit r25056.
2021-03-15 15:14:28 +00:00
ab53a351ba Fix siege_attack tech not affecting Maurya.
Patch by: borg-
Accepted By: Nescio, wraitii
Differential Revision: https://code.wildfiregames.com/D3655
This was SVN commit r25055.
2021-03-15 10:15:00 +00:00
7026d1a702 Fix typo in prop-point of Iberian blacksmith.
Patch by: @nwtour
Differential revision: D3667
Reviewed by: @Stan
This was SVN commit r25054.
2021-03-15 08:49:52 +00:00
6bd30fe150 Elephant_stables -> elephant_stable.
- Renames the elephant_stables.xml templates to elephant_stable.xml
(without plural s), as well as their generic template_*.xml parent,
consistent with e.g the stable.
- Corrects all occurrences in simulation and map files accordingly.
- Renames the stable and elephant stable audio files.
- Drops pers_ from the barrack.png and stable.png icons.

Patch by: @Nescio
Differential revision: D3343
This was SVN commit r25053.
2021-03-15 08:45:09 +00:00
8dc86d20bb Improve Army camp and Amun temple tooltips.
Mention they train ranked entities.

Patch by: @borg-
Differential revision: D3677
Reviewed by: @Nescio
This was SVN commit r25052.
2021-03-15 08:34:37 +00:00
Angen
2f5c99776e Fix 85f8d97859
This was SVN commit r25050.
2021-03-14 13:00:13 +00:00
Angen
85f8d97859 Add missing queueplanBuilding.js changes lost somewhere when updating D3654
This was SVN commit r25049.
2021-03-14 12:59:10 +00:00
Angen
6598433108 Call get without has in getEntityById
getEntityById calls .has before actually getting the entity by .get and
otherwise returns undefined.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get

The element associated with the specified key, or undefined if the key
can't be found in the Map object.

So calling has is redundant causing performance loss.

Differential revision: D3653
Reviewed by: @Freagarach
This was SVN commit r25048.
2021-03-14 12:45:08 +00:00
Angen
665f16d1bb Let Petra to build apartments
Teach her to build advanced houses available for cart players as they
provide more population.

Reviewed by: @Freagarach
Differential revision: D3654
This was SVN commit r25047.
2021-03-14 12:43:19 +00:00
56047ac9fa Adds logs to CameraController for speed changes of camera scroll, rotate and zoom.
Patch By: nwtour
Differential Revision: https://code.wildfiregames.com/D3604
This was SVN commit r25045.
2021-03-12 20:57:33 +00:00
f1e1edad43 Move movement logic from UnitAIs "Garrisoned"-state to approaching.
Reduces switching of states, improves readability.

Refs. #6081
Differential revision: D2368
Comments by: @Stan, @wraitii
This was SVN commit r25044.
2021-03-12 19:53:52 +00:00
90831d5d88 Let PetraAI use the GarrisonHolder from cmpGarrisonable instead of UnitAI.
References 3851a48298.

Differential revision: D3645
Reviewed by: @Angen
This was SVN commit r25043.
2021-03-12 19:47:31 +00:00
4d58b0729e Moves CreateDateTimeInstance from the public L10n header to its implementation.
This was SVN commit r25042.
2021-03-12 09:11:22 +00:00