1
0
forked from 0ad/0ad
Commit Graph

1042 Commits

Author SHA1 Message Date
ffc4a56b9f Revert non-ASCII characters from source and configuration files introduced in 157c6af18e.
Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185
This was SVN commit r27965.
2023-12-03 00:30:12 +00:00
1bccfef6fb Don't use std::shared_ptr in ScriptInterface
Differential Revision: https://code.wildfiregames.com/D5159
This was SVN commit r27945.
2023-11-19 20:13:19 +00:00
0fec859267 Fix serialization test following 7350b9042e - Fix CalculateTerritories after deserialization
This fixes an issue revealed by 7350b9042e that affected deserialized
games.
Adding tests further highlighted a bug in the calculations, which is
fixed.

Reviewed By: phosit
Fixes #6883

Differential Revision: https://code.wildfiregames.com/D5181
This was SVN commit r27928.
2023-11-11 10:34:24 +00:00
3fb7319df7 Reverts 080599442f as it breaks LOS update. Fixes #6844
Accepted By: wraitii
Differential Revision: https://code.wildfiregames.com/D5162
This was SVN commit r27893.
2023-10-20 21:44:41 +00:00
e2c5a62a19 Moves model flags to ModelAbstract.
Differential Revision: https://code.wildfiregames.com/D5146
This was SVN commit r27880.
2023-10-09 18:37:56 +00:00
b7ef2f2d72 Provides entity ID for unit in its constructor.
Refs 2eac4af3a4, refs 56bb858802, 91ad17c685, 72bd886f80.

Differential Revision: https://code.wildfiregames.com/D5110
This was SVN commit r27818.
2023-08-28 18:01:44 +00:00
bb
157c6af18e Make the space in 0 A.D. non-breaking throughout the codebase.
Avoid cases of filenames
Update years in terms and other legal(ish) documents
Don't update years in license headers, since change is not meaningful

Will add linter rule in seperate commit

Happy recompiling everyone!

Original Patch By: Nescio
Comment By: Gallaecio
Differential Revision: D2620
This was SVN commit r27786.
2023-07-27 20:54:46 +00:00
85bc074ae5 Moves script interface Object include out of FunctionWrapper header.
Differential Revision: https://code.wildfiregames.com/D5067
This was SVN commit r27755.
2023-07-07 20:12:16 +00:00
64efa0acf9 Delay a distance computation in UnitMotion.
Minor optimisation to computing a point goal.

Differential Revision: https://code.wildfiregames.com/D5035
This was SVN commit r27700.
2023-06-14 07:48:45 +00:00
9399ba043e Speed up AI computation by not using structured clones
Following the AI unthreading in 4df03ed2d2 / D3769, structured clones
are no longer needed to pass the gamestate around.
This is much faster, about 10-15% wall time on an AI 1v1 profile.

This also potentially reduces memory fragmentation and GC needs, as
writing clones allocated a lot of data.

Differential Revision: https://code.wildfiregames.com/D5019
This was SVN commit r27698.
2023-06-14 07:32:22 +00:00
080599442f Don't send PositionChanged messages in TurnTo when not actually turning
FaceTowardsTarget is called quite often by UnitAI, and we can skip some
un-necessary messages as an optimisation.

Differential Revision: https://code.wildfiregames.com/D5005
This was SVN commit r27695.
2023-06-14 07:23:05 +00:00
7350b9042e Don't poll territory in Position component
CmpPosition::TurnStart checks whether the territory changed underneath
each entityevery turn. The only user of this is TerritoryDecay
(structures, for the most part). It is rather inefficient to have this
done for all entities.
The simplest solution is to listen to position-changed messages in
TerritoryDecay instead. This should hardly ever happen in vanilla 0
A.D., except in Atlas, so it's basically free.

This sort of reverts 19965ce37a (original implementation) and
c44b48bd59.

Accepted By: Freagarach (concept only)
Differential Revision: https://code.wildfiregames.com/D5009
This was SVN commit r27673.
2023-06-13 15:48:03 +00:00
ded41eab31 Allow other root XML than entity.
Implements a `GetOnlyChild()`, following discussion at
https://irclogs.wildfiregames.com/%230ad-dev/2022-05-06-QuakeNet-%230ad-dev.log.

Differential revision: https://code.wildfiregames.com/D4738
Comments by: @phosit, @Stan, @vladislavbelov, @wraitii
This was SVN commit r27323.
2022-12-30 07:34:23 +00:00
a333c8f355 Use Future::CancelOrWait in pathfinder Deinit
If the pathfinding tasks are running, they might reference now-deleted
variables. CancelOrWait prevents this.
Remove `Future::Cancel()` altogether as that was its only use and the
functions seems dangerous.

Introduced with 0ebc08b13c

Patch by: phosit
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D4831
This was SVN commit r27310.
2022-12-28 11:34:04 +00:00
f4c730a887 Reduces the uniform size of an instancing transform of overlay solid shader.
This was SVN commit r27209.
2022-11-06 20:04:26 +00:00
557fa0312e Fix non-visual autostart, as well as client/host autostart.
Follows 8eecc39e71.

Piping the autostart through a GUI page is easy but requires using the
GUI in non-visual mode, which is problematic since it's not initialized.
The GUI is not needed, only its ability to load scripts, so this diff
fixes the problem by adding an 'entrypoint' script in the new
`autostart` folder that gets called with this unique ability, setting
things up properly. The mod mod gets a placeholder.

Other changes:
- Fix some issues with networked autostart:
  - Players were not assigned slots.
  - The host didn't actually wait for other players.
- Move gamesettings from `gui/gamesettings/` to `gamesettings/`. This
moves attributes as well.
- Move autostart files from `gui/autostart/` to ` autostart/`. Note that
`gui/autostart/` still exists as it's used in the tutorial button from
the main menu.
- Rename the JSI_VFS functions to be explicitly about their function:
the ability to write and the potential restricted folders.
- Don't require `autostart` when using `--autostart-client` in
non-visual mode.

Starting the autostart client/host has poor UX in some situations, but
improving that feature is beyond the scope of this diff.

Suggestions for future work:
- Some files in gui/common should probably be moved elsewhere
- Template loading code is duplicated
- The gamesetup code still needs work for proper UI/logic separation.

Help & comments by: smiley

Reported by: vladislav / Langbart
Fixes #6513

Differential Revision: https://code.wildfiregames.com/D4628
This was SVN commit r26879.
2022-05-15 06:34:17 +00:00
ed4e07e594 Allow setting the passability class depending on formation members.
Improves pathfinding for the general case (no large entities in a
formation).

Differential revision: https://code.wildfiregames.com/D4605
Comments by: @marder, @Stan, @wraitii
This was SVN commit r26873.
2022-05-11 14:47:16 +00:00
2ccd1ba280 UnitMotion - Fix Clearance serialization and only allow changing passability of formation controllers.
Fixes 5de50c447c

Changing the passability class at runtime breaks some UnitMotion
assumptions in unrecoverable ways and will lead to units getting into
impassable terrain.
Formation controllers can tolerate it since units still check their own
obstruction.
Until some code is added to recover from the above bad case,
de-activated changing passability class for non-formation controllers.

This also fixes serialization issues related to clearance & passability
classes following that diff.

Reviewed By: Freagarach
Differential Revision: https://code.wildfiregames.com/D4629
This was SVN commit r26865.
2022-05-09 17:29:15 +00:00
5de50c447c Allow setting the passability class dynamically. This is needed to improve formation behavior for the release.
Accepted by: @Freagarach
Refs: https://code.wildfiregames.com/D4563,
https://code.wildfiregames.com/D4605
Differential Revision: https://code.wildfiregames.com/Dr4599
This was SVN commit r26801.
2022-04-17 11:06:09 +00:00
ce3a47e49a Fix passibilty overlay in atlas
Broken in bb49fbe793.

Patch by: nwtour
Fixes #6374

Differential Revision: https://code.wildfiregames.com/D4338
This was SVN commit r26663.
2022-03-17 15:17:49 +00:00
41f2ab87ed Fixes macOS warnings after adding final keyword to simulation classes in 3eee3a444d.
Also fixes GLES.

Differential Revision: https://code.wildfiregames.com/D4528
This was SVN commit r26605.
2022-03-07 23:04:11 +00:00
ce18f297d5 Adds icons to minimap.
Tested By: Langbart, Stan
Differential Revision: https://code.wildfiregames.com/D4513
This was SVN commit r26592.
2022-03-07 01:22:06 +00:00
3eee3a444d Adds final keyword to simulation component classes.
Differential Revision: https://code.wildfiregames.com/D4520
This was SVN commit r26537.
2022-03-03 22:42:26 +00:00
6a2a297c0e Clean LoadPlayerSettings in Player-helper.
- Removed obsolete C++-side `addPlayer`, introduced in 4fed9b8242, moved
out of Atlas in 1c0536bf08, unused after 9ee44bd9b8.
- Get the player settings from a local function (avoids passing
arguments).
- Removed setting the standard diplomacy (done in cmpPlayerManager since
132020f88e).
- Create entity when adding a player instead of creating it and
instructing the playermanager to add it.
- Changed/Removed some comments.

Differential revision: https://code.wildfiregames.com/D4482
Comments by: @Stan
This was SVN commit r26404.
2022-02-18 08:10:13 +00:00
bb
3484a3d483 Move parabolic range computation to rangemanager
Co-proposed By: Freagarach
Reviewed By: Freagarach
Test written By: Stan
Comments By: vladislavbelov, stan, wraitii, Silier
Depricates: D4356

Differential Revision: D3249
This was SVN commit r26392.
2022-02-15 20:31:55 +00:00
4de89c3db1 Moves texture management to CDeviceCommandContext, adds quality options.
Comments By: nwtour, Stan
Tested By: nwtour, Stan
Differential Revision: https://code.wildfiregames.com/D4488
This was SVN commit r26365.
2022-02-13 19:30:28 +00:00
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
0e403632cf Allow giving different weights to different templates when pushing.
This makes it possible to make units heavier, which both push more & get
pushed less by other units.
In particular, the diff does it for siege units & elephants.

This improves movement for these units in crowd situation, since they
will now basically not move when other regular units push into them.

Supported By: asterix, marder
Refs #6127

Differential Revision: https://code.wildfiregames.com/D4452
This was SVN commit r26275.
2022-01-30 14:22:27 +00:00
4df03ed2d2 Run the AI in the same Compartment as the simulation. Let the AI access Sim data.
This is a paradigm change for AI computation.
Historically, the AI was intended to be run in a separate thread from
the simulation. The idea was that slow AI wouldn't stop the renderer
from being smooth.

In that original design, the AI received a copy of the game world and
used that to run its logic. This meant the simulation could safely do
whatever it wanted in the meantime. This copy was done via AIProxy &
AIInterface.

This design ended up having significant flaws:
- The copying impacts the simulation negatively, particularly because
AIProxy subscribes to a lot of messages (sometimes sent exclusively to
it). This time cannot be threaded, and impacts MP games without AIs.
- Copying the data is increasingly difficult. Modifiers are a headache,
LOS is not implemented. Lots of logic is duplicated.

The intended benefits of the design also failed to realise somewhat:
- The AI was never threaded, and in fact, it is probably better to try
and thread Sim + AI from the renderer than just the AI, at which point
threading the AI specifically brings little benefit.

The new design is much simpler and straighforward, but this has some
side-effects:
- The AI can now change the simulation. This can be used for cheating,
or possibly for a tutorial AI.
- The AI runs in the same GC zone as the simulation, which may lead to
more frequent Sim GCs (but overall we might expect a reduction in
temporary objects).
- The AI state was essentially cached, so replacing some functions with
Engine.QueryInterface might be slower. The tradeoff should be balanced
by lower AIProxy computation times.

Future work:
- Threading some specific AI tasks could still be worthwhile, but should
be done in specific worker threads, allowed to run over several turns if
needed.

Technical note: the AI 'global' is in its own Realm, which means name
collisions with the same are not possible.

Other notes:
- The RL Interface uses the AI Interface and thus will gradually lose
some data there. Given that the RL Interface can now request data
however, this should be dine.

Refs #5962, #2370

Differential Revision: https://code.wildfiregames.com/D3769
This was SVN commit r26274.
2022-01-30 13:33:34 +00:00
e0d98cd94d Call SetTerrainDirty on CModelAbstract without going through CmpVisualActor
The UnitManager already lists all units, so we do not need to go through
the visual actor of entities to update them. This is faster and
decouples simulation & graphics code slightly.

Further, the simulation does not need to know about texture changes (see
also 410d2e883a), so remove those calls in Atlas.

Differential Revision: https://code.wildfiregames.com/D4455
This was SVN commit r26270.
2022-01-29 08:28:04 +00:00
410d2e883a Remove leftover terrain-based movement cost code.
6581796103 removed the ability for terrain to affect movement speed. The
JPS pathfinder cannot support it, and the approach was poor anyways,
coupling rendering data with simulation data.
This lets us remove the dependency on CTerrainTextureManager everywhere.

Tested by: langbart
Differential Revision: https://code.wildfiregames.com/D4459
This was SVN commit r26269.
2022-01-29 08:22:28 +00:00
158cf8ea8d UnitMotion pushing improvements
The main change is the introduction of a 'pushing pressure' counter on
units. This counter increases when units get pushed around, and
decreases over time. In essence, units under high pressure move slower &
are harder to push around.
The major effect is that units can now get bogged down when very dense
groups start colliding. This makes movement more realistic, makes unit
movement more 'chokepointy', and generally improves the mathematical
soundness of the system (lower values are easier to handle for our 200ms
turns).

Other changes:
- The logic to detect units crossing each other's path has been
reworked. Units that run towards each other should not more obviously
avoid each other.
- New parameters: 'Spread' is a measure of how strong the pushing effect
is based on distance. With the current settings, static-pushing is
rather 'on/off', whereas moving-pushing is more gradual (and thus the
max influence distance was increased when moving).
- Default values have been tweaked for lower overlap.
- Units only looked at other units within their grid region. This led to
overlap near grid-borders. Units now look at neighboring grid elements,
which largely removes this issue. While this may be slower, the
performance of pushing was largely negligible before, so it is unlikely
to become a main cause of lag (and overlap was generally disliked by
players).
- Units no longer orient in the direction of pushing, but instead keep
facing their target. This can look slightly odd under very heavy pushing
forces, but vastly improves behaviour of very slow units such as rams
(since they spend much less time turning around). As a side-effect,
clean up angle code following acc780bcbb .

Engine changes:
- Add a debug rendering mode at compile-time to help understand what is
happening.
- Make it possible to constexpr initialise fractional fixed numbers by
using FromFraction

The 'pressure' change was inspired by alre's suggestion at
https://wildfiregames.com/forum/topic/56436-for-a-better-unit-movement/#comment-461987

Refs #6127

Differential Revision: https://code.wildfiregames.com/D4439
This was SVN commit r26245.
2022-01-24 15:36:13 +00:00
87b5c233c5 Splits CRenderer part about scene to CSceneRenderer.
Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D4412
This was SVN commit r26165.
2022-01-04 13:29:01 +00:00
4fba543488 Unifies providing SkyManager and WaterManager like other managers, refs b889826a3d.
This was SVN commit r26158.
2022-01-03 10:49:12 +00:00
809e3ed0bd Removes rand function usage from tests to avoid non-uniform distributions.
This was SVN commit r26012.
2021-11-25 17:57:59 +00:00
bb
c1cd28c878 Also do a postMove update when the average speed over last turn isn't zero
Reviewed By: Freagarach
Differential Revision: D4302
refs acc780bcbb

This was SVN commit r25985.
2021-10-31 17:21:04 +00:00
bb
acc780bcbb Add accelerations in unit movement.
This helps preventing arrow dodging.

Differential Revision: D3200
Reviewed By: Freagarach
Comments By: wraitii, vladislav, Palaxin, Stan
refs: #5106

This was SVN commit r25953.
2021-10-09 21:31:11 +00:00
645e053fd2 Remove executable bit on some source files.
Reported by: Ralph Sennhauser
Fixes: #6325

This was SVN commit r25917.
2021-09-12 18:41:51 +00:00
a5c82a4ef6 Removes unused forward declarations of class and struct.
This was SVN commit r25903.
2021-09-08 19:43:01 +00:00
0ba9cbef74 Fix units changing appearance when switching animation.
Bug introduced in 76acc4e146.
The previous CUnit code had logic to select random aesthetic variants
once initially. The new code removed that, as I completely missed its
purpose, assuming that the random selection, being based on a seed,
would pick the same variants every time. This is incorrect because
entity selections can change the RNG calls, thus the variants, and thus
entity appearance can change when the animation changes (typically, a
horse will change color when walking and running).

The solution is to re-introduce the choice of actor selections on CUnit
creation. This makes sure that units don't change their purely-aesthetic
selections when e.g. animations change.

Reported by: Wowgetoffyourcellphone
Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D4205
This was SVN commit r25844.
2021-07-31 17:55:10 +00:00
Angen
ae744f13f3 Prevent formation members to run when they should not
Reported on forum:
https://wildfiregames.com/forum/topic/41264-alpha-25-pre-releaserelease-candidate-build-testing/page/13/
Introduced in: 40cbde1925
Differential revision: D4201
Tested by: @Freagarach, @marder
This was SVN commit r25841.
2021-07-27 18:20:26 +00:00
f189172db6 UnitMotion hack to fix units being stuck near corners.
I think there is a small mismatch between CheckMovement & the vertex
pathfinder when computing passability because one is ray-based and the
other just uses edges. However, it's out of my reach to fix it for now.
This can lead to units being stuck near building edges occasionally.
This introduces an un-intrusive recovery strategy (aka a hack) in
HandleObstructedMove that should get the units unstuck.

Should fix #6114 (to a sufficient extent anyways)

Differential Revision: https://code.wildfiregames.com/D4162
This was SVN commit r25786.
2021-06-13 08:43:32 +00:00
870e689e5f Unit pushing: fix pairs of unit being allowed to overlap.
Following 40cbde1925, the minimum pushing force is 0.2. This also
happens to be the maximum pushing force any pair of units can exert on
each other, so they can freely overlap instead of being pushed.

This tweaks settings slightly to fix that problem.

Reported by: marder
Differential Revision: https://code.wildfiregames.com/D4129
This was SVN commit r25748.
2021-06-08 16:38:06 +00:00
83703992c9 Fix speed glitch
Introduced in 40cbde1925
MoveToFormationOffset may be called after the formation controller is
reset, leading to issues. It seems best to trust only
SetMemberOfFormation.

This causes the speed glitch experienced by wow & Valihrant.

Differential Revision: https://code.wildfiregames.com/D4128
This was SVN commit r25747.
2021-06-08 16:03:31 +00:00
40cbde1925 Further Pushing tweaks: more customisable, longer ranges.
This overall decreases the deathball effect from units walking to each
other a bit.
- Fix formations - this cleans up a UnitMotion hack for formations,
making it possible to increase pushing ranges without breaking closely
knit formations like testudo.
- Make MINIMAL_PUSHING and the MOVE_EXTENSION configurable, and add a
STATIC_EXTENSION as well.
- Increase the pushing range significantly, making units sparser.

Differential Revision: https://code.wildfiregames.com/D4098
This was SVN commit r25708.
2021-06-06 15:25:52 +00:00
3745940de8 Fix OOS in unit motion
Fixes 592453c62f
wasObstructed and wentStraight are not reset when Move() isn't called,
but PostMove may still be called (if the unit was pushed). This will
OOS.

Differential Revision: https://code.wildfiregames.com/D4088
This was SVN commit r25686.
2021-06-05 09:33:57 +00:00
0ebc08b13c Thread the pathfinder computations using the task manager.
The pathfinder computations are run asynchronously (and potentially on
the main thread) in-between simulation turns, thus reducing
pathfinder-related lag considerably in common cases.

To make this most efficient, the number of paths computed during a turn
via MaxSameTurnMoves is reduced from 64 to 20.

This has a hard dependency on the obstruction manager (via the vertex
pathfinder) not being modified in-between simulation turn (or to put it
more generally on the simulation state not changing outside of turn
computation), otherwise results will be non-deterministic and go OOS.
This is currently entirely safe (as in, it indeed does not happen that
the simulation state changes in-between turn), but future work towards
improving simulation sandboxing would be good.

Thanks to Kuba386 for maintaining & improving the patch in 2020
Thanks to everyone who tested the various iterations of this patch.

Fixes #4324

Differential Revision: https://code.wildfiregames.com/D14
This was SVN commit r25657.
2021-06-03 16:21:28 +00:00
48ea6ee7d2 Moddability for pushing: radius in XML, allow deactivating globally/some templates.
Differential Revision: https://code.wildfiregames.com/D4040
This was SVN commit r25635.
2021-06-02 17:36:32 +00:00
b927f163d6 Adds std namespace to shared_ptr usages in scriptinterface and simulation.
This was SVN commit r25528.
2021-05-22 19:30:18 +00:00
b6f2dee43b Increase pushing range by 60%
Reduces the 'clumpiness' of units, particularly when ordered to move to
a single point. The minimum pushing force was increased to compensate.

Differential Revision: https://code.wildfiregames.com/D3978
This was SVN commit r25479.
2021-05-21 07:23:47 +00:00