1
0
forked from 0ad/0ad
Commit Graph

21788 Commits

Author SHA1 Message Date
7ba4b1ffc8 Split dropping resources from approaching in UnitAI.
Allows for non-moving entities to drop resources. (When someone checks
those cases in the order.)
(Also makes it easier for us to implement a duration for the dropping in
the future, might we ever want to.)

Differential revision: D3817
This was SVN commit r25215.
2021-04-09 06:25:47 +00:00
6023a273df Fix phasing requirements of tutorial.
Introduced in 2ef3fd7a77.
Fixed by switching the order of task of the barracks and outpost.

Patch by: @nwtour
Differential revision: D3820
This was SVN commit r25214.
2021-04-09 06:02:22 +00:00
294d102a6f Queue techs at structure with the lowest queue length.
Instead of queueing all techs at the lowest ID.

Patch by: @n1xc0d3r
Differential revision: D3798
Tested by: @Langbart
This was SVN commit r25213.
2021-04-09 05:55:05 +00:00
f5a0ab81b6 Fix missing return in 3c4a341906.
Caused entities to walk to the edge of the map when their dropsite was
destroyed.

This was SVN commit r25211.
2021-04-08 10:34:48 +00:00
76acc4e146 Implement quality levels for actors & corresponding setting.
An actor file, as referenced by the VisualActor, can now define
different actors for different "quality level" setting.
In this initial version, the quality is handled directly by the object
manager.

Actor format impact:
- '<qualitylevels>' may be used as the root node, containing actor nodes
as children.
  - such actor nodes can refer to a file, or to an inline actor, or
simply be inlined.
  - such actor nodes may have a 'quality' attribute, specifying the
maximum quality level of this actor. By default, 255 (the maximum) is
implied.
- The actor format remains valid, but 'groups', 'variants', 'material',
'castshadow' and 'float' can be given a [minquality, maxquality[ range
via XML attributes. Outside of this range, the XML node is ignored
(making it possible to define, in a single actor file, several quality
levels).

Quality is a 0-255 value, with:
- Range 0-99 intended for lower level-of-detail actors (billboards,
etc.)
- Range 100-200 the 'normal' range for models. 100 is "low", 150
"medium", and 200 "high".
- Range 201-255 used for higher quality actors that might be used for
e.g. cinematics.
The range is wide to make it easier to add intermediate levels in the
future and it seemed easier given that an integer value of some kind was
required anyways.

Engine impacts:
- A new CActorDef class is introduced, wrapping an art/actors XML file
and its different quality levels. ObjectBase remains the definition of a
given 'actor', now at a given quality level.
- CActorDef imposes a maximal # of quality level for a particular actor
definition (5 currently).
- CUnit is made to refer to an Actor Definition explicitly, not a
particular ObjectBase.
- As a minor optimisation, variation keys are calculated on
pointer-to-sets-of-selections, instead of raw sets-of-selections, as
this reduces copying.
- some refactoring, including better const-correctness and hotloading
support via std::shared_ptr.

Differential Revision: https://code.wildfiregames.com/D3787
This was SVN commit r25210.
2021-04-08 07:22:24 +00:00
e3695abe59 Build using Builder instead of UnitAI.
Moves the building logic from UnitAI to Builder.
Makes it easier for modders to change building behaviour, e.g. letting
structures build.

Differential revision: D3812
Comment by: @Angen
This was SVN commit r25208.
2021-04-08 05:50:18 +00:00
f2d5603422 Heal using Heal instead of UnitAI.
Moves the healing logic from UnitAI to Heal.
Makes it easier for modders to change healing behaviour, e.g. letting
structures heal (instead of using an aura).

Differential revision: D2680
Comments by: @Stan, @wraitii
This was SVN commit r25207.
2021-04-08 05:40:49 +00:00
3c4a341906 Gather using ResourceGatherer instead of UnitAI.
Moves the gathering logic from UnitAI to ResourceGatherer.
Makes it easier for modders to change gathering behaviour, e.g. letting
structures gather.
Refs. #4293 by optimising a bit.

Differential revision: D2662
Comments by: @bb, @Stan, @wraitii
This was SVN commit r25206.
2021-04-08 05:31:34 +00:00
48d6b84c62 Fix initial animation sync.
UpdateAnimationID → PickAnimationID

Reviewed by: @wraitii
Differential Revision: https://code.wildfiregames.com/D3747
This was SVN commit r25205.
2021-04-07 08:35:02 +00:00
a7d777d69b Don't store origin market in this.goods in cmpTrader.
It was introduced in 9b98585275 but made obselete in 98b4fe6d00.

Differential revision: D3809
This was SVN commit r25204.
2021-04-07 07:04:57 +00:00
9ee4ccd8ec Split commit from build in cmpFoundation.
Useful if e.g. a modder wants to commit a structure before building it.

Differential revision: D3806
This was SVN commit r25203.
2021-04-07 07:02:12 +00:00
ac7db9850b Move trader gain to cmpMarket.
Deletes the helper, since we need at least one market anyway.

Differential revision: D3808
Closes: #5890

This was SVN commit r25202.
2021-04-07 06:58:36 +00:00
739a63828a Suppress CppCheck "unknown macro" lint error.
Including third party libraries to the cppcheck include path is annoying
and the unknownMacro errors are generally not useful.

This was SVN commit r25200.
2021-04-06 15:20:35 +00:00
f1e4a0e6f6 Some cleaning in cmpFoundation.
- `var` -> `let`.
- Remove some comments.

Differential revision: D3803
This was SVN commit r25199.
2021-04-06 13:35:29 +00:00
e208b703ca Only tell stuff to move from foundation when trying to commit it.
It is wasteful to do and seems not needed anymore.

Differential revision: D3802
Comments by: @Angen, @Stan
Reverts b478b9742a, b478b9742a
Refs. #3410

This was SVN commit r25198.
2021-04-06 13:06:27 +00:00
5b3bdf3647 Use transform to finish construction.
Decreases duplication.

Differential revision: D3804
Comment from: @wraitii (also on IRC)

This was SVN commit r25197.
2021-04-06 12:54:33 +00:00
973de1ccd7 Fix foundation committing following 592453c62f (pushing)
592453c62f added a flag to "GetBlockMovementFlag" to return either the
current or the template value, and by default it returns the template
value.
Foundation logic needed it to return the current value.

Gates are also updated to avoid changing behaviour in unpredictable
ways.

Differential Revision: https://code.wildfiregames.com/D3796
This was SVN commit r25196.
2021-04-06 12:28:53 +00:00
80f354a125 Fix nopch / tiny hotkey optimisation
Swap an std::set for an std::vector, the set was useful only in an
earlier iteration of the diff. This fixes nopch.

Differential Revision: https://code.wildfiregames.com/D3790
This was SVN commit r25195.
2021-04-06 12:26:34 +00:00
93d22ef16b Allow to specify subunits on creation.
This basically does two things:
- Allow turrets on moving entities (fixes serialisation in cmpPos).
- Allow an entity to be present on another when the other is created.

That makes it basically a boiled down version of a prior patch, omitting
the part where orders could be passed on.
This does allow e.g. ranged units on chariots that fire while the
chariot moves.

Original diff by: @sanderd17
Redone by: @Stan
Differential revision: D1958
Comments by: @Alexandermb, @Angen, @bb, @Langbart, @Nescio, @Stan,
@wraitii
Refs. #2577 by implementing the entity on platform case.

This was SVN commit r25192.
2021-04-05 05:22:25 +00:00
e2f4ce0649 Add Upkeep component.
Adds a new component effectively handling negative resource trickles.
Prevents resources from going negative and provides an effect for not
being able to pay.
The effect chosen for 0 A.D. is having the entity not being
controllable.

Not used in the public mod itself, but it is in quite some mods.

Based on an idea of @Nescio
Differential revision: D1323
Comments by: @Angen, (@smiley,) @Stan
This was SVN commit r25191.
2021-04-04 06:52:20 +00:00
7562354c49 Don't pass owner to initialise a foundation.
As ownership is already set.
Refs. bdbd0b9dbf and 9213ee8c27.

Differential revision: D3795
This was SVN commit r25190.
2021-04-04 06:38:16 +00:00
58ec287b1f Use interval instead of timeout for healing in GarrisonHolder.
Prevents constant recreation of a timeout.

Differential revision: D3791
Refs. #6081

This was SVN commit r25189.
2021-04-04 06:32:53 +00:00
0d630fb113 Fix garrison rally point when unloading.
Revealed by f884848745. Noticed by @Langbart.
The holder was deleted after being tasked to garrison the new target,
but with still a holder we were not allowed to garrison.

Differential revision: D3794
Closes: #6128
Tested by: @Lanbart
This was SVN commit r25188.
2021-04-04 05:57:42 +00:00
7032a3c12a Further hotkey work: clear hotkeys when an input box/the console gets focus.
This is necessary following 2d53308e1b, which now handles key-up in
input to prevent hotkeys from firing then.
Hotkeys are a global system, which means opening e.g. the chat window or
the summary does't reset things. If you press "S" to scroll the in-game
camera down, then press 'return' to open the chat, the camera keeps
scrolling down. Following 2d53308e1b, it never released since it never
got the keyup.

To handle this nicely, we need to explicitly clear hotkeys when input
boxes get focus (respectively the console).

Differential Revision: https://code.wildfiregames.com/D3797
This was SVN commit r25186.
2021-04-03 20:12:40 +00:00
52e8a0c5fb Fix chasing after Motion Manager & Pushing.
The motion manager introduced in bae258f9a1 makes 'chasing' (e.g. an
entity targeting another entity, which also applies to fleeing)
behaviour symmetrical: both units see the initial state instead of it
being ID-dependent.
This allows removing hacks introduced in 6a66fb8205 (and refined in
7b88b1a0f9).

Differential Revision: https://code.wildfiregames.com/D3785
This was SVN commit r25185.
2021-04-03 07:00:58 +00:00
fb498d97d9 Fix raising alert.
After 21e866fcf0.
AllertRaiser replaced the order instead of just calling the required
function.
While at it, check for the garrisonable size when looking for buildings.

Differential revision: D3789
Tested by: @Langbart
This was SVN commit r25183.
2021-04-02 17:01:59 +00:00
592453c62f Add a simple 'pushing' logic to unit motion to improve movement.
This implements a form of crowd movement that I've generally called
'unit pushing' in the last few years.
Essentially, any two units will push each other away when they're too
close. This makes it possible to ignore unit-unit obstructions, and thus
makes movement much smoother in crowds.
This first iteration of this system only allows pushing between idle
units and between moving units (i.e. a moving unit does not affect an
idle one).
This is because the unitMotion logic to detect it is stuck & needs to
use the pathfinders starts breaking: units can fail to move because they
are pushed away from their intended movement, and the current logic
fails to handle this gracefully.
Thankfully, the most value of this patch in terms of player experience
is found in the improvements to group movements and shuttling.

Other impacts:
- As the short pathfinder is called less often, we can increase the
starting search range & reduce the # of max turns, both improving
collision recovery.
- The performance of idle units is slightly worsened, as they must be
checked for idle-idle collisions. If needed a 'sleeping' system, as used
in physics engine, could be implemented.
- In general, however, expect slight performance improvements, as fewer
short paths are computed.
- Gathering efficiency should increase slightly, since shuttling times
are likely reduced slightly.
- As a sanity change to improve some edge cases (units that say they're
moving, i.e. pushable, but don't actually move), the 'going straight'
logic is turned off if a short path has been computed. This requires a
few cascading changes to work correctly.

Technical notes:
- To reduce the cost of the n^2 comparisons that pushing requires, units
are only compared within a small square on a grid which is lazily
reconstructed each turn. The overhead seems rather small, and this is
much simpler than keeping an up-to-date grid.
- The design is intended to be parallelisable if needed someday.
- The pathfinder's CheckMovement ignores moving units in UnitMotion, as
that is now the spec. Idle units are not ignored, which is required for
the 'collision' detection to work correctly (see above).

Refs #3442 (not fixed - idle units are not pushed by moving units).
Fixes #5084 (the overlap can still happen, but units will push each
other away).

Differential Revision: https://code.wildfiregames.com/D1490
This was SVN commit r25182.
2021-04-02 16:30:59 +00:00
8ed1bc2fd1 Don't error in the network delay notifier.
Differential Revision: https://code.wildfiregames.com/D3788
This was SVN commit r25181.
2021-04-02 14:20:37 +00:00
2d53308e1b Fix console not preventing hotkeys from firing / Clean up hotkey-input conflict.
- Fix mistake in 4b46c09222 (similar to one in a4852c4c01) that allowed
hotkeys to fire while typing in the console.
- Prevent Alt+key to fire hotkeys in input boxes & console as that is
often text input.
- Split the hotkey triggering logic in two: a preparatory phase & an
actual firing phase.
This allows the GUI code to check which hotkeys are about to fire and
selectively allow them to go through. This makes it easier to change
hardcoded hotkeys, such as the console toggling one.

Differential Revision: https://code.wildfiregames.com/D3786
This was SVN commit r25180.
2021-04-02 14:18:20 +00:00
6842eacde9 Fix allowed classes on turret points.
Should use `_string` on init. Noticed by @wraitii.

Differential revision: D3783
This was SVN commit r25178.
2021-04-02 07:15:46 +00:00
0232c0d017 Fix 4b46c09222 - Mouse wheel hotkeys behaving erratically.
Mouse wheel hotkeys behave differently from other hotkeys (mouse
button/keys) in that they are transient: they're always pressed/released
in one go.
As such:
- They shouldn't be added to the stored pressedHotkeys
- They shouldn't be added to active scancodes.

This fixes these issues from 4b46c09222 & also skips un-necessary
processing in those cases.

Reported by: Imarok.
Differential Revision: https://code.wildfiregames.com/D3782
This was SVN commit r25176.
2021-04-01 14:51:22 +00:00
ae1bc9b785 Show non-default hotkeys that appear in JSON spec files in the hotkey editor.
This makes sure all hotkeys from hotkeys/spec/*.json files are displayed
in the editor, even if they are not found in configuration files.

Differential Revision: https://code.wildfiregames.com/D3767
This was SVN commit r25175.
2021-04-01 09:20:29 +00:00
28bd4f0092 Introduce a 'Builder' class for entities that can build structures.
- Increases moddability
- Increases the clarity of visible classes (gatherer & builder vs
Worker)
- Introduce an 'Idle builder' hotkey.

Patch by: Nescio
Differential Revision: https://code.wildfiregames.com/D3290
This was SVN commit r25174.
2021-04-01 07:26:59 +00:00
1b5ed5063f Cleanups CGUISprite, removes redundant method.
This was SVN commit r25172.
2021-03-31 19:26:05 +00:00
22ea79a56f Fix the 'Introductory Tutorial' found in the 'tutorial campaign'.
Some information & resources were outdated, preventing progress.

Patch by: nwtour
Differential Revision: https://code.wildfiregames.com/D3764
This was SVN commit r25171.
2021-03-31 15:58:16 +00:00
b55b236379 Remember OOS on a per-client basis.
Change the OOS notification logic to remember the OOS-ness of each
client. Reset it on client leave.
The server will thus continue checking for OOS if the OOS-client leaves.
This is convenient to ignore observer OOS, or wait for an OOS player
without restarting the game.

Also add the turn number to the OOS dump, to fix #3348: particularly
following d4c2cf4430 the turn is likely to not be the same between
different clients.

Agree by: asterix
Differential Revision: https://code.wildfiregames.com/D3753
This was SVN commit r25170.
2021-03-31 15:55:19 +00:00
4b46c09222 Do not trigger "HotkeyPress" events when releasing a key.
Follows d0a42f2f00.
Because only the most specific hotkeys can be active at any time,
releasing a key may require re-activating less specific hotkeys.
There were two issues with this behaviour:
- It was buggy, as it only checked one active key, when any still active
key can trigger hotkeys.
- "HotkeyPress" and "HotkeyDown" events where sent, as if the hotkey was
pressed, which was unexpected for most code/users (it is unusual to have
a "Press" event on key release).

This fixes these issues by "silently" re-triggering the hotkeys in such
a case. It also makes it easier for JS code to use "hotkeyPress" instead
of "hotkeyDown" for non-continuous behaviour.

Accepted By: nani
Fixes #6123
Refs #6064 (fixes the problem, but not the code weirdness)

Differential Revision: https://code.wildfiregames.com/D3766
This was SVN commit r25169.
2021-03-31 15:50:25 +00:00
457c538780 GameSetup: fix selecting a map with up/down keys.
Fixes dc18d94030.
Using down/up to change the map in the map selection dropdown in the
gamesetup has a one-element lag. The reason is that on dropdown up/down,
two events are sent:
- first the current highlighted item is selected (it's usually the
selected one).
- then the new item is selected.

Because of faulty timer logic, only the first update went through.

Differential Revision: https://code.wildfiregames.com/D3774
This was SVN commit r25168.
2021-03-31 13:10:07 +00:00
6c6204f007 Add missing player number to skirmish map names & filenames.
Patch by: langbart
Fixes #6105

Differential Revision: https://code.wildfiregames.com/D3682
This was SVN commit r25167.
2021-03-31 06:53:05 +00:00
742b636f70 Moves CRect from ps to maths to related geometric primitives.
This was SVN commit r25165.
2021-03-30 21:14:36 +00:00
f50c98cfd1 Check for ability to move on orders that need to move.
Not all orders were checked, which would cause problems when receiving
an order that needed moving and that did not handle not being able to
move properly.

Differential revision: D3771
This was SVN commit r25164.
2021-03-30 15:50:03 +00:00
496884ac73 Some fixes after the split of turrets.
21e866fcf0
Crossbowmen should be able to turret (noted by @Nescio).
TurretHolders should be able to pick entities up.

Differential revision: D3744
This was SVN commit r25163.
2021-03-30 11:24:08 +00:00
fd1d7d5d83 Reduce UnitAI duplication in range checks.
By querying the range and passing a target along.

Differential revision: D3748
Comments by: @wraitii
This was SVN commit r25162.
2021-03-30 11:17:46 +00:00
649cc49f25 Fix off-by-one error in d8ea401a95.
d8ea401a95 replaced the ExploreTerritories logic, but I did not account
for the territory grid being N cells wide when the LOS is N+1.
Therefore, we could get out of bounds.

Reported by: Vladislavbelov
Differential Revision: https://code.wildfiregames.com/D3765
This was SVN commit r25161.
2021-03-30 07:11:44 +00:00
c56c856ed5 Moves Frustum from graphics to maths to more related geometric primitives like bounding ones.
This was SVN commit r25159.
2021-03-29 17:28:13 +00:00
4f83f1a0e9 Cleanups Frustum and removes access to members.
This was SVN commit r25158.
2021-03-29 17:15:29 +00:00
e5b971c2bf Allow modifiers without "affects" list.
This allows modifiers without "affects", or with empty "affects" lists,
to do something.
This makes it possible to force a modifier on an entity without classes
(e.g. trees) or with unknown classes.

Accepted By: asterix
Differential Revision: https://code.wildfiregames.com/D3761
This was SVN commit r25157.
2021-03-29 08:10:08 +00:00
5ebf2020b0 Netcode: allow observers to lag behind the live game.
Observers no longer lag the game for players. There is still some time
to serialise the game when sending it to a joining observer, and
depending on the chosen 'max lag' the game may stop while observers
sufficiently catch up, but this impact too is reduced.

- Make the NetServerTurnManager ignore players marked as 'observers' for
the purpose of ending a turn, effectively making it possible for
observers to lag without it affecting the players in any way.
- Add a config option (network.observermaxlag) that specifies how many
turns behind the live game observers are allowed to be. Default to 10
turns, or 2 seconds, to keep them 'largely live'.
- The controller is not treated as an observer.
- Implement a simple UI to show this delay & allow the game to speed up
automatically to try and catch up. This can be deactivated via
network.autocatchup.
- Move network options to the renamed 'Network / Lobby' options page.
- Do not debug_warn/crash when receiving commands from the past -
instead warn and carry on, to avoid DOS and "coop play" issues.

Refs #5903, Refs #4210

Differential Revision: https://code.wildfiregames.com/D3737
This was SVN commit r25156.
2021-03-29 07:53:06 +00:00
e3a254225a Introduce generic template for support elephants.
To keep civ-specific stuff in civ-specific templates.

Patch by: @Nescio
Differential revision: D3690
This was SVN commit r25154.
2021-03-29 06:59:34 +00:00
969112b9c8 Replaces CPos by more a consistent CVector2D, reduces geometry code duplication.
Tested By: Freagarach, Langbart
Differential Revision: https://code.wildfiregames.com/D3759
This was SVN commit r25152.
2021-03-28 21:55:13 +00:00