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.
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.
- 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.
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.
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.
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.
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.
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.
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.
- 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.
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.
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.
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.
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.
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.
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.
Commented By: Stan
Reported By: Freagarach
Tested By: Freagarach, Stan
Differential Revision: https://code.wildfiregames.com/D3059
This was SVN commit r24129.
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.
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.
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.
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.