1
1
forked from 0ad/0ad
Commit Graph

7354 Commits

Author SHA1 Message Date
a4852c4c01 Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.
- Provide a "Hotkey" screen to let players remap hotkeys in-game using a
convenient setup.
- Make all .cfg hotkeys refer to scancodes (i.e. position on the
keyboard), so that default hotkeys now translate correctly for AZERTY,
QWERTZ and other layouts.
- 'BackSpace' is now an alias for 'Delete', and works for killing units.
This fixes #1917, as macs don't have a proper delete key and would need
to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.

Functionally, this switches hotkeys to scancodes, as that makes more
sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.

Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.

Follows work in 3d7784d2af.

Various diffs tested by: Angen, Stan, Freagarach
Comments by: Nescio
Differential Revision: https://code.wildfiregames.com/D2814
This was SVN commit r24215.
2020-11-19 09:27:26 +00:00
fd8f5abd2e [SM52 2/2] Update to Spidermonkey 52 APIs.
No particularly noteworthy changes, as most complex API changes were
already supported in SM45 and done.
The addition of JSStructuredCloneData allows to remove our custom class.

Changes:
- InformalValueTypeName is back in the API, so remove our
implementation.
- Stop using JSRuntime entirely in favour of JSContext*
- JSPropertyDescriptor is renamed.
- CompartmentOptions are tweaked slightly (no functional changes)
- JS::Construct - API update.
- JSClass split - API update.
- A js.msg error message was removed, so we had to use a different one.
- Tests fix: fix comparison of union instances
- Disable warning in spidermonkey Vector.h
- Update error reporting to SM52 (minor API updates)
- Ignore warnings about unused return values (would come from OOM, which
isn't recoverable)

Most of the patching was done by Itms.

Tested by: Stan, Freagarach
Fixes #4893

Differential Revision: https://code.wildfiregames.com/D3095
This was SVN commit r24203.
2020-11-18 14:39:04 +00:00
6bb08fb424 [SM52 1/2] Upgrade Spidermonkey build system and binaries to 52.9.1
Of note is the change to static linking on *nix (MacOS already used it).
The logic is that we can only use one single version of SM, so that
advantage of dynamic linking is lost regardless. We might also see
performance gains in the future with LTO enabled. It is also slightly
easier to distribute the program as a result. Expect a negligible size
increase in the binary size (offset somewhat by no longer needing to
distribute .so files). Finally, it streamlines the build script.

Also noteworthy in this commit:
- The MacOS build script is folded back into the general build script.
- the perl/sed command is replaced by patching the configuration file,
which at least warns if it starts failing in the future.

Binaries for windows provided by @Itms
The bulk of the patching was also done by @Itms.

Tested by: Stan, Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3094
This was SVN commit r24202.
2020-11-18 14:34:17 +00:00
935af751b9 Fix building without precompiled headers.
Broken in several recent diffs.
This also fixes (very) old missing standard headers.

Differential Revision: https://code.wildfiregames.com/D3110
This was SVN commit r24200.
2020-11-18 11:35:36 +00:00
0f2b00326f Notify players with a sound when a player is defeated
Includes alarm_defeated_ally.ogg by @Samulis

Reviewed by: @bb
Comments by: @Angen Freagarach
Differential Revision: https://code.wildfiregames.com/D2860
This was SVN commit r24199.
2020-11-18 09:14:08 +00:00
9937116f2b Adds MSAA to anti-aliasing techniques.
Tested By: Freagarach, OptimusShepard, Stan
Differential Revision: https://code.wildfiregames.com/D2812
This was SVN commit r24188.
2020-11-15 20:07:48 +00:00
25490bfec3 Improve JS Exception handling.
- Check for pending exceptions after function calls and script
executions.
- Call LOGERROR instead of JS_ReportError when there is a conversion
error in FromJSVal, since that can only be called from C++ (where JS
errors don't really make sense). Instead, C++ callers of FromJSVal
should handle the failure and, themselves, either report an error or
simply do something else.
- Wrap JS_ReportError since that makes updating it later easier.

This isn't a systematical fix since ToJSVal also ought return a boolean
for failures, and we probably should trigger errors instead of warnings
on 'implicit' conversions, rather a preparation diff.

Part of the SM52 migration, stage: SM45 compatible (actually SM52
incompatible, too).

Based on a patch by: Itms
Comments by: Vladislavbelov, Stan`
Refs #742, #4893

Differential Revision: https://code.wildfiregames.com/D3093
This was SVN commit r24187.
2020-11-15 18:29:17 +00:00
88bc973530 Delete useless JS::Value forward declaration.
ProfileViewer.h forward-declares JS::Value but doesn't use it. Starting
in SM68, JS::Value is a union, and this breaks at compilation.

Last modified in c02a7e1a7b, useless since 2af94c5898

Differential Revision: https://code.wildfiregames.com/D3102
This was SVN commit r24186.
2020-11-15 07:51:15 +00:00
bb
768c84aa46 Optimize the GUI event broadcast
Patch By: nani
Differential Revision: D2638
This was SVN commit r24185.
2020-11-14 21:54:17 +00:00
10c3bcbf5f Allow right-click on disabled buttons.
Reviewed by: @Angen
Fixes #5269
Fixes #5095

Differential Revision: https://code.wildfiregames.com/D2651
This was SVN commit r24184.
2020-11-14 18:16:24 +00:00
6b5fe442c7 Remove unused function that triggers warnings on Windows.
This was SVN commit r24183.
2020-11-14 18:11:58 +00:00
2f29b81027 Fix JS OOM in tests following aae417bd29
aae417bd29 made ScriptInterface not recreate a new JSContext since it
becomes a compartment wrapper, but that means we need to GC tests or
they might OOM.

To make it mostly seamless, GC on any test setup. The JS tests are
pretty close to the 16Mb limit as it stands so GC them manually too, for
good measure.

Refs #4893

Differential Revision: https://code.wildfiregames.com/D3101
This was SVN commit r24182.
2020-11-14 15:13:56 +00:00
aa15066c69 Rename ScriptRuntime to ScriptContext
SM52 essentially replaces JSRuntime with JSContext (though JSContext
itself was replaced with JSCompartment).
To prepare for this migration, rename all Runtime-related things to
Context.

Part of the SM52 migration, stage: SM45 compatible.

Patch by: Itms
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3091
This was SVN commit r24181.
2020-11-14 10:57:50 +00:00
aae417bd29 Explicitly make ScriptInterface a Compartment wrapper.
ScriptInterface is now a wrapper around a JSCompartment, and thus always
has a well-defined global.

The error reporter is moved to ScriptRuntime in anticipation of that
handling JSContext in a later diff.

Part of the SM52 migration, stage: SM45 compatible.

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3090
This was SVN commit r24180.
2020-11-14 08:46:32 +00:00
ab5616b4c4 Mass rename CxPrivate to CmptPrivate.
As part of the SM45->52 migration, a ScriptInterface becomes a wrapper
around a JSCompartment, not a JSContext, thus we ought to store private
data for the compartment and not the context.
This is a mass rename of CxPrivate to CmptPrivate to match that before
the actual changes.

Part of the SM52 migration, stage: SM45 compatible

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3089
This was SVN commit r24177.
2020-11-13 16:44:15 +00:00
ee0d204bf6 Wrap JSAutoRequest and replace usage of JSContext* with the wrapper.
JSAutoRequest is required before calling into most JSAPI methods, for GC
reasons.
Calling it is required and fragile as one must not forget.
Further, SM52 and later make manipulating JSContext* dangerous as that
can cross Compartment(Realm in SM68) barriers (and ScriptInterface now
matches a Compartment).

The solution to both problems is to avoid using JSContext* in 0 A.D.
itself. To achieve this, a Request class is introduced, and must be used
to access a JSContext* from a scriptInterface. Further, Request is
passed to other ScriptInterface functions isntead of JSContext*, making
it obvious that the caller has already called it, reducing errors and
redundant JSAutoRequest calls.
Only JSNative functions now get a naked JSContext* without protection,
but the likelihood of forgetting a request is lower since many
ScriptInterface functions now expect it.

JSContext* is directly passed to JSAPI functions only.

Part of the SM52 migration, stage: SM45 compatible

Based on a patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3088
This was SVN commit r24176.
2020-11-13 13:18:22 +00:00
6a029d2a84 Fix incorrect README.txt following 849cbc13ee.
This was SVN commit r24175.
2020-11-13 10:50:48 +00:00
66cc595c53 Encapsulate runtime creation.
- Makes it easier to change down the line (and change is coming)
- Allows making g_ScriptRuntime thread-local easily.
- Remove ParentRuntime, which is not used at the moment.

Part of the SM52 migration, stage: SM45 compatible.

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3087
This was SVN commit r24171.
2020-11-12 09:34:40 +00:00
90367cdc53 Remove DefPersistentRooted and unneeded includes.
DefPersistentRooted is essentially a wrapper around unique_ptr and has
no real reason to exist.

Part of SM52 migration, stage: SM45 compatible.

Patch by: Itms
Tested by: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3086
This was SVN commit r24170.
2020-11-12 08:24:30 +00:00
ace639f96f Use JS::Trace over CallXTracer
CallXTracer functions were removed in
https://bugzilla.mozilla.org/show_bug.cgi?id=1235598

Part of the SM52 migration, stage: SM45 compatible.

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3092
This was SVN commit r24169.
2020-11-12 08:04:24 +00:00
dad2857538 Use Symbols to store JS object references when serialising and delete ObjectIDCache
When serialising JS objects, we keep track of any encountered object,
and serialize it only once. Any further serialisation instead stores an
ID referring to the original object (essentially an opaque pointer).
The trouble of course is to have a unique, persistent identifier for
such an object.
svn uses an ObjectIDCache, essentially a "JS Object -> ID" map (which
internally is essentially a "JS heap pointer -> ID" map).

JS, since ES15, includes a "Symbol" primitive type, which is a unique,
immutable identifier. They are also not iterable by for..in or
GetOwnPropertyName or related.
This means they can be used to store the tag directly on the object
(since it's impossible overwrite a user property).
Thanks to this, we can forgo ObjectIDCache in the serializers, and since
following D2897 it becomes unused, we can delete it, along with the
Finalization code it used.


Part of SM52 migration, stage: SM45-compatible changes.

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3085
This was SVN commit r24167.
2020-11-12 06:40:19 +00:00
b5df81af76 Store turret positions in map files.
Follow up on 8bfb449375. Allows saving turret positions in the map file,
instead of relying on the order in which the entities are added.

Differential Revision: D2614
Reviewed by: @wraitii
Comments by: @Angen, @bb, @vladislavbelov.
This was SVN commit r24161.
2020-11-11 19:40:44 +00:00
9669b5f1a9 Removes additional depth texture copying and reusing existing refraction depth.
Tested By: Stan, wraitii
Differential Revision: https://code.wildfiregames.com/D3084
This was SVN commit r24160.
2020-11-11 18:46:52 +00:00
f22449bf24 Remove serializablePrototype code
The script interface has code to serialize/deserialize JS objects with a
user-defined prototype. That code is usable in the AI, but currently
unused (and there are no plans to use it in the long run).

Removing it allows removing more code down the line, which helps with
the SM45-52 migration.

Collaboration with itms.

Refs #4893

Differential Revision: https://code.wildfiregames.com/D2897
This was SVN commit r24157.
2020-11-11 08:43:13 +00:00
e038f7844b Fixes terrain overlays by removing fixed pipeline dependency.
Tested By: Freagarach, wraitii
Differential Revision: https://code.wildfiregames.com/D3074
This was SVN commit r24154.
2020-11-09 18:50:40 +00:00
bb8456691b Avoid overflow in UnitMotion.
ComputeTargetPosition called Dot() with large enough vectors that it
overflowed. Avoid that by not actually doing the full dot product.

Reported by: Itms
Fixes #5852

Differential Revision: https://code.wildfiregames.com/D3061
This was SVN commit r24152.
2020-11-09 13:25:50 +00:00
61c6da91e8 Moves foam calculation into a separate function and fixes its lighting.
Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D3071
This was SVN commit r24145.
2020-11-08 22:17:58 +00:00
8c77c4b2b6 Refactors coordinates of SOverlayTexturedLine, replaces array of floats by array of CVector2D.
Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D3072
This was SVN commit r24144.
2020-11-08 14:47:25 +00:00
4b52e87934 Adds wireframe mode to overlays and replace the private m_TerrainRenderMode usages by related getter.
This was SVN commit r24143.
2020-11-08 11:31:32 +00:00
ad7ac8d595 Fix UpdateComponents logic for pathfinding following d592bf9cb6
Following d592bf9cb6, paths requested at turn N were set-up to be
computed between the end of turn N and the start of turn N+1 (which
would ultimately allow threading this computation), via calls to
'StartProcessingMoves' and 'FetchAsyncResultsAndSendMessages'.

However, the call to UpdateGrid() remained at the start of turn N+1,
between the 'start' and 'fetch' calls. Since all paths are currently
computed on the 'start' call, this means all paths are computed on a
(possibly) dirty pathfinder grid.
In particular, this leads to OOS on rejoin since the rejoiner will
recompute the grid before computing the outstanding paths.

This would also obviously be buggy in a threaded environment, since some
paths might be computed on the fresh and some on the dirty grid.

Finally, MT_TurnStart was sent before the paths were computed, which
might lead to further pathfinder grid changes (not a crashing problem
without threading, but still conceptually odd). The 'fetch' call is thus
moved before it.
This thus fixes d592bf9cb6/D1918, after 92ad6a61fa already fixed a first
issue.

Since the grid is now only updated at the end of a turn, we need to
ensure that it is correct on Turn 0, thus the pathfinder recomputes it
on InitGame.

Refs D14

Reported by: Itms
Fixes #5851

Differential Revision: https://code.wildfiregames.com/D3064
This was SVN commit r24142.
2020-11-08 08:58:19 +00:00
9d53bed0bd Adds a LOS mask to Minimap.
Commented By: elexis, Stan
Differential Revision: https://code.wildfiregames.com/D2216
This was SVN commit r24141.
2020-11-08 08:51:54 +00:00
ada16439ab Fix the random slowdowns and speedups on AMD CPUs for Windows
Remove the MAHAF code and binaries, which doesn't work on anything more
recent than Windows XP due to the usage of an unsigned driver.
Remove the custom timer (PMT, TSC...) code to use the Windows
recommended way aka, QueryPerformanceCounter (QPC)
Remove the deprecated functions in wpthread relating to this. Some
further cleanup will be needed, but this patch is already big enough.

This patch voluntarily excludes the Linux Fix for further investigation
as we haven't ruled out a kernel bug yet;

Discussed with: @wraitii, @vladislavbelov, @janwas, AMD Inc,
Tested by: Dakara, @OptimusShepard, Stan (On W10, Win7; with and without
PCH)

Threads:
https://wildfiregames.com/forum/topic/28367-amd-ryzen-threadripper-user-read-before-posting/
https://wildfiregames.com/forum/index.php?/topic/26890-problem-with-ryzen-3000er-series/page/3/

Differential Revision: https://code.wildfiregames.com/D2726
This was SVN commit r24137.
2020-11-06 23:18:16 +00:00
b7cbfecd19 Replacing losMap usages by existed and more consistent losTex.
losMap was introduces in fe21c5e023.

This was SVN commit r24130.
2020-11-04 22:55:34 +00:00
ad965e167d Moves simple water from fixed pipeline to shader pipelines (ARB/GLSL).
Commented By: Stan
Reported By: Freagarach
Tested By: Freagarach, Stan
Differential Revision: https://code.wildfiregames.com/D3059
This was SVN commit r24129.
2020-11-04 22:25:08 +00:00
2d54653bc3 Little cleanup of PatchRData by reordering includes and correctly formats some loops.
This was SVN commit r24126.
2020-11-04 15:53:33 +00:00
c64f8824d7 Fixes wireframe mode for terrain, continuing remove fixed pipeline dependencies.
Commented By: Stan, wraitii
Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D3056
This was SVN commit r24125.
2020-11-04 15:52:26 +00:00
d7d02a4740 Moves terrain lighting calculation to GPU.
Reviewed By: wraitii
Tested By: OptimusShepard, Stan, wraitii
Differential Revision: https://code.wildfiregames.com/D3052
This was SVN commit r24124.
2020-11-04 12:54:17 +00:00
770280436b Removes FFP option from Atlas and adds ARB/GLSL selection.
Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D3055
This was SVN commit r24123.
2020-11-04 12:21:55 +00:00
6e3db3d84c Removes remaining fixed program used in shader pipelines and adds check on FFP create.
Commented By: Stan
Differential Revision: https://code.wildfiregames.com/D3048
This was SVN commit r24121.
2020-11-03 18:59:27 +00:00
478f96d0fd Fix Atlas crash in RangeManager following 939002f0dc
939002f0dc changed from vectors to grid which broke resetting when
terrain size changed.
Also use SAFE_ARRAY_DELETE for simplicity.

Reported by: vladislavbelov
Reviewed By: vladislavbelov
Differential Revision: https://code.wildfiregames.com/D2961
This was SVN commit r24117.
2020-10-31 10:21:08 +00:00
413003fe4f Fix a compartment mismatch in XmppClient, causing crashes in MP games.
Added in 9023f4bebb, which changed lobby GUI messages to JS::Values,
requiring a real context. The original code mistakenly inverted the
owning script interfaces.

Given the reproducibility discovered in SM52, the timeline of the bug,
and the nature of the issues encountered in MP, this is a rather safe
fix for #5655.

Reviewed By: Itms
Fixes #5655

Differential Revision: https://code.wildfiregames.com/D2922
This was SVN commit r24116.
2020-10-31 10:13:33 +00:00
03f9522ff4 Remove useless SDL debug message introduced in 5593f573f4.
Reviewed by: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D3050
This was SVN commit r24112.
2020-10-27 21:19:33 +00:00
acc254533b Refactors water shader to move refraction in a separate function.
Commented By: Angen, asterix, linkmauve, Stan, wraitii
Reviewed By: Angen
Tested By: Angen, asterix, linkmauve, Stan
Differential Revision: https://code.wildfiregames.com/D2908
This was SVN commit r24110.
2020-10-25 21:00:52 +00:00
Angen
dcdc17b2dd Do not use GPUSkinning without glsl [Crash fix]
Disable GPUSkinning when glsl is disabled, because VertexAttribPointer
is not implemented on ARB/GLES and it is called by GPUSkinning.

Differential Revision: D2423
Reviewed by: vladislavbelov
Fixes: #5635

This was SVN commit r24101.
2020-10-13 16:48:04 +00:00
bb
c93bd91ef6 Do not hardcode attacktypes in the engine/Atlas
fixes 0ad79096bd
refs #252, D368
Reviewed By: vladislavbelov
Comments By: Stan, wraitii
Differential Revision: D2998
This was SVN commit r24095.
2020-10-10 15:12:17 +00:00
acfd466c32 Fixes crash with mod packing on a wrong path.
Reviewed By: Stan
Differential Revision: https://code.wildfiregames.com/D3026
This was SVN commit r24087.
2020-10-04 10:17:34 +00:00
1273307b58 Don't detect audio card when audio is disabled, Fix compilation with --without-audio, fix a few warnings.
Reviewed by: @bb
Comments by: @vladislavbelov, @wraitii
Differential Revision: https://code.wildfiregames.com/D2809
This was SVN commit r24079.
2020-10-02 07:35:59 +00:00
Angen
69a13c2be5 Refactor UpdateMessageSubscriptions in CCmpRangeOverlayRenderer
Introduced in 5fbb224dc0

rewrite 3 ifs to 1 if
merge 2 member variables into 1 member variable
remove 2 function local variables
save one call for CComponentManager as both ifs would or execute or not

code is shorter and looks nicer

Differential Revision: D3009
Reviewed by: bb
This was SVN commit r24072.
2020-09-27 13:12:30 +00:00
b0e4eecdfe Fix map serialization bug in aeaba3c14c and 8190dd9054.
Reviewed by: @Angen
Differential Revision: https://code.wildfiregames.com/D2974
This was SVN commit r24051.
2020-09-20 09:33:18 +00:00
ff9a5fe8f9 Render waves for fancy water effects only if we have water on screen.
Waves were added in 9ce51f4357.

This was SVN commit r24047.
2020-09-16 18:43:58 +00:00