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.
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.
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.
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.
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.
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.
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.
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.
- 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.