1
0
forked from 0ad/0ad
Commit Graph

150 Commits

Author SHA1 Message Date
d92a2118b0 [SM78 2/2] Update to Spidermonkey 78 APIs
This ugprades 0 A.D. to the latest ESR at the moment of writing.

Mostly straighforward API changes (see meta-Bug 1633145)
- js::Class is merged with JSClass
- JSNewArrayObject becomes JS::NewArrayObject
- ArrayObject-functions are moved to a new public header Array.h
- JSMSG error messages have again been changed, requiring some tweaks.
- AutoValueArray becomes RootedBalueArray (Bug 1634435)
- 'uneval' is behind a Realm flag (Bug 1565170), but no removal is
planned in the short-term future.
- Some minor GC API changes (Bugs 1569564 and 1633405)
- Error reporting has had some tweaks, and error flags have been removed
(Bug 1620583)
- StructuredClone are now always thread-safe, simplifying an API change
introduced in SM52 (Bug 1607791)

Tested by: Stan, Freagarach, mammadori
Closes #5861

Differential Revision: https://code.wildfiregames.com/D3168
This was SVN commit r24333.
2020-12-06 14:03:02 +00:00
9ae084519f Fix most of the new vs2017 induced warnings.
Refs: https://code.wildfiregames.com/D3096
https://code.wildfiregames.com/D3103 #5862
Reviewed by: @wraitii
Comments by: @Angen
Differential Revision: https://code.wildfiregames.com/D3126
This was SVN commit r24268.
2020-11-26 22:28:50 +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
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
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
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
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
aeaba3c14c Use victory conditions json's in Atlas
Reviewed by: @Angen
Differential Revision: https://code.wildfiregames.com/D2393
This was SVN commit r23847.
2020-07-18 17:39:59 +00:00
fc08fe60ab Support testing rejoins on turn 0, refs #3460, #4242, #5185, #5162, 2bf1dbfd13
Differential Revision: https://code.wildfiregames.com/D1522
This was SVN commit r22998.
2019-09-26 12:09:19 +00:00
35408e7e7e Save replay metadata for non-visual games too, refs #4577, #5548, fixes #5565.
Remove gui/common/ hack by going through the GUIInterface and fragile
EndGame() hardcoding by saving if and only if a ReplayLogger exists
following 7470e88624, refs #4020.
Refs D2211, D2213.

Differential Revision: https://code.wildfiregames.com/D2197
Based on patch by: irishninja
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22991.
2019-09-25 10:06:12 +00:00
d592bf9cb6 Move path computations to an actual worker to prepare for threading.
This moves the "async" pathfinding computations to a worker, preparing
the architecture for threading.

Tested By: Kuba386, Stan`
Differential Revision: https://code.wildfiregames.com/D1918
This was SVN commit r22902.
2019-09-15 09:27:10 +00:00
a84e2e57df Use ScriptInterface::CreateObject for ToJSVal<CColor>, and for ToJSVal<Grid<u8> >, ToJSVal<Grid<u16> > used by the AIManager obtaining the pathfinder grid.
Make that function static, so that it can be used for these functions
without slowly having to obtain the ScriptInterface instance using
GetScriptInterfaceAndCBData just to get the JSContext again.
Remove few redundant conversions for CreateObject arguments.

Differential Revision: https://code.wildfiregames.com/D2128
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Tedious performance testing in: D2128, D2127

This was SVN commit r22894.
2019-09-13 00:56:51 +00:00
b4626359f5 Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later.
Differential Revision: https://code.wildfiregames.com/D2080
Previous version reviewed By: Krinkle
Comments By: historic_bruno, wraitii
This was SVN commit r22528.
2019-07-22 19:35:14 +00:00
262b27d770 Remove unnecessary argument from CSimulation2::InitGame
Reviewed By: Itms
Differential Revision: https://code.wildfiregames.com/D1289
This was SVN commit r21166.
2018-02-09 19:50:01 +00:00
7e05d7edc9 Initialize the AIManager AISeed immediately in C++ rather than too late and in JS.
Fixes #4907
Differential Revision: https://code.wildfiregames.com/D1178
Reviewed By: mimo
Refs D1159, f88ee2766e

This was SVN commit r20700.
2017-12-27 16:51:25 +00:00
f7206dc77d More ScriptInterface const.
Reviewed By: elexis; some comments by bb
Differential Revision: https://code.wildfiregames.com/D863
This was SVN commit r20519.
2017-11-25 06:49:58 +00:00
ce580f0de0 Always delete CMapReader. Patch by Sandarac. Fixes #4154.
This fixes an assertion failure in ScriptEngine that can occur when
closing
the game while in the loading screen.

Reviewed By: vladislavbelov, leper
Differential Revision: https://code.wildfiregames.com/D684
This was SVN commit r20035.
2017-08-25 00:37:48 +00:00
9defd11440 Pass ScriptInterface as a const ref where possible.
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D739
This was SVN commit r20028.
2017-08-24 00:32:42 +00:00
51f62818f7 Fix all broken checks for the absent (random-mapgen+simulation) Seed property in the engine, refs #3965.
Hence display the originally intended useful warnings (instead of the
characterless JS "Script value conversion check failed" warning and
skipping the intended warnings).

This was SVN commit r19718.
2017-06-02 15:07:58 +00:00
2bf1dbfd13 An awesome Rejoin-test tool by wraitii and Itms, fixes #4242, refs #3460.
Contrary to the serializationtest, initializes the secondary simstate
only once
before progressively applying updates.
Thus reproducing actual multiplayer rejoining, enabling developers to
analyze OOS reports solely from the replay file of the rejoined and a
non-rejoined client.

This was SVN commit r18940.
2016-11-15 13:26:58 +00:00
6eaf76d653 Actually seed the random number generator used in the simulation. Reviewed by sanderd17, fixes #4127.
This was SVN commit r18604.
2016-08-14 16:28:54 +00:00
bb1f86f515 Remove duplication of the Hexify function.
Remove the useless extern keyword from function declarations in
ps/Util.h.

Patch by echotangoecho, refs #4095

This was SVN commit r18591.
2016-08-08 12:50:39 +00:00
4c0f12bce3 Fix autostart replays following a23884d79a by grabbing g_GameAttributes from the simulation instead of the GUI. Patch by Imarok, refs #3143.
Don't remove attribs from the init attributes as that is still used by
the loading screen to show the mapname.

This was SVN commit r18510.
2016-07-12 01:49:48 +00:00
898ab5229b Change profiling calls to get a better view of what is actually slow and what is not.
This was SVN commit r18438.
2016-06-25 13:12:35 +00:00
6f744aef88 Simulation context cleanup, refs #3991, #3168.
Save the viewed player in the CGame class.
Add the const keyword back to the SimContext to help find mistakes at
compiletime.

This was SVN commit r18201.
2016-05-19 19:42:07 +00:00
f4e69b7c07 Cleanup of #3255, fixes #3966.
Don't create an empty oos_logs directory when starting the game.
Rename getDateIndexSubdirectory to createDateIndexSubdirectory.
Add a comment for the breakpoint argument of CreateDirectories.

This was SVN commit r18183.
2016-05-16 00:56:07 +00:00
d61e315f4d Fix few style issues remarked by leper.
Add a unit (seconds) to the network-timeout warning.
Rename isChatAddressee to parseChatAddressee as it changes the message.
Early return for EnableOOSLog to avoid printing duplicate messages.

This was SVN commit r17895.
2016-03-15 04:37:41 +00:00
b155a28698 Immediately set the fog-of-war instead of waiting for session.js to load, refs #3168.
This was SVN commit r17832.
2016-03-06 13:56:07 +00:00
a32ed75bff Fix a race-condition when two games have been started simultaneously and attempt to create the same replay directory, refs #3255.
Instead of triggering a debug-breakpoint, print a warning to stdout and
succeed in the N'th retry when having started N processes
simultaneously.
Previously the problem had been addressed by using the processID in the
directory name.

This was SVN commit r17776.
2016-02-19 11:22:32 +00:00
5998d13442 Use date and sequential ID for replay-directorynames, fixes #3255.
Save replays in userdata (screenshots, savegames)  and create one
subdirectory for every release.

This was SVN commit r17761.
2016-02-15 15:57:23 +00:00
a2f7d4d82a Show fog of war in observermode, fixes #3168.
This was SVN commit r17735.
2016-02-06 12:56:41 +00:00
5747619c39 Don't create replays without commands in case of running non-visual replay or an atlas simulation.
Remove trailing whitespace.

This was SVN commit r17689.
2016-01-23 01:02:57 +00:00
f34dc412b6 Deep freeze simulation commands to prevent accidental updates. Fixes #3647.
This was SVN commit r17673.
2016-01-18 22:24:50 +00:00
d08044c8ad JS_DumpHeap is removed in SpiderMonkey 38, since we have nothing using it remove it. Refs #3708.
https://bugzilla.mozilla.org/show_bug.cgi?id=1105069
https://bugzilla.mozilla.org/show_bug.cgi?id=1122842

This was SVN commit r17630.
2016-01-11 20:03:09 +00:00
71b0d9c052 Update atlas with the new map_sizes.json format. Refs #3355.
This was SVN commit r17379.
2015-12-04 16:37:30 +00:00
700859b2c3 Move the playerdefaults to the settings directory. Refs #3355
This was SVN commit r17332.
2015-11-30 01:33:59 +00:00
ba82743777 Some range-based for loops.
This was SVN commit r16926.
2015-08-20 12:58:41 +00:00
b2e8a241d2 Properly check loaded scripts in the second simulation instance of a serialization test. Fixes #3238
This was SVN commit r16925.
2015-08-20 12:52:29 +00:00
1ab3a4a02d Fix 6506bc20cb, refs #3238
This was SVN commit r16924.
2015-08-20 12:49:43 +00:00
c5eb9b7bb7 Range-based for for VfsPath loops.
This was SVN commit r16893.
2015-07-29 23:44:12 +00:00
ae4dfe294d Actually state the file instead of the directory in some error messages.
This was SVN commit r16802.
2015-06-21 18:46:33 +00:00
6581796103 New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.

An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.

Running update-workspaces is needed after this change.

Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563

This was SVN commit r16751.
2015-06-12 18:58:24 +00:00
6506bc20cb Fixes #3238, SetGlobal 'TriggerHelper' called multiple times
This was SVN commit r16713.
2015-06-03 20:34:59 +00:00
2042e6b2d4 Added TriggerScripts Reload(Hotloading) when you change the file and save
This was SVN commit r16546.
2015-04-16 04:30:51 +00:00
4e763ef26e Move civ JSON files to simulation/data. Patch by MattDoerksen. Fixes #2562.
This was SVN commit r16485.
2015-04-01 23:48:33 +00:00
c02a7e1a7b SpiderMonkey 31 upgrade
This upgrade also introduces exact stack rooting (see to the wiki:
JSRootingGuide) and fixes problems with moving GC. This allows us to
enable generational garbage collection (GGC).
Measurements a few months ago have shown a performance improvement of a
non-visual replay of around 13.5%. This probably varies quite a bit, but
it should be somewhere between 5-20%. Memory usage has also been
improved. Check the forum thread for details.

Thanks to everyone from the team who helped with this directly or
indirectly (review, finding and fixing issues, the required C++11
upgrade, the new autobuilder etc.)! Also thanks to the SpiderMonkey
developers who helped on the #jsapi channel or elsewhere!

Fixes #2462, #2415, #2428, #2684, #1374
Refs #2973, #2669

This was SVN commit r16214.
2015-01-24 14:46:52 +00:00
568c415d0a Convert wchar_t*/wstring arguments to UTF-8 strings in CLogger messages.
This was SVN commit r16188.
2015-01-22 20:37:38 +00:00
e02d7ad949 Automatically replace %hs/%ls with %s in CLogger format strings.
Everything is char* now, so we don't need to mess around with different
string types.

Done with:

  ag -ls 'LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR)' source | xargs perl
-pi -e'1 while
s/(LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR).*)%[hl]s/$1%s/g'

This was SVN commit r16187.
2015-01-22 20:36:24 +00:00
38a8e2e0d6 Automatically convert most path.string().c_str() to path.string8()
Done with:

  ag -l 'LOG.*string\(\).c_str\(\)' source | xargs perl -pi -e'1 while
s/(LOG.*string)\(\)\.c_str\(\)/${1}8()/g'

This was SVN commit r16186.
2015-01-22 20:35:17 +00:00