1
1
forked from 0ad/0ad
Commit Graph

86 Commits

Author SHA1 Message Date
e009d322cc Add missing files in 4942cabab5
This was SVN commit r24488.
2020-12-31 14:27: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
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
bb
5cfce692e7 Implement keyDown event
Change HotkeyPress event to be non-repeating (HotkeyDown to replace the
repeating case)
Fix shiftlag
Make toggle hotkeys only respond to the first SDL event.

Many iterations of review by: elexis
Test done by: Imarok
Comments By: vladislav, Stan
Reviewed By: wraitii
Fixes: #5055
Differential Revision: https://code.wildfiregames.com/D1398
This was SVN commit r23701.
2020-05-26 21:47:03 +00:00
8abc7c051b Include Pyrogenesis.h and os_path.h where needed
These two headers were missing in various places, preventing build in
some cases.

Patch By: linkmauve
Tested By: Freagarach
Differential Revision: https://code.wildfiregames.com/D2481
This was SVN commit r23321.
2020-01-02 18:07:40 +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
508da732af Implement NetClient PushGuiMessage using parameter pack and ScriptInterface::CreateObject from D2080 / b4626359f5 to replace remaining Eval function calls.
Specialize ToJSVal<char[n]> to allow passing string literals as
arguments.
Freeze NetClient GUI messages.
Supersede related c-style casts with static casts.
Remove few unneeded conversions.

Differential Revision: https://code.wildfiregames.com/D2267
Tested: clang 8.0.1, Jenkins

This was SVN commit r22867.
2019-09-07 16:51:44 +00:00
da4e601d8f Move GetDefaultGuiMatrix to a separate file.
The function was located in the wrong file, because it is not logically
related to IGUIObject settings.
The separate file allows the various users to include it without
including the GUIRenderer.

This was SVN commit r22605.
2019-08-04 03:52:00 +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
2af94c5898 Remove disabled remains of the performance data (= profiler data + text input) upload feature from the UserReporter from 0da7e822ff.
User-submitted text upload was removed in 2779512c6e in preference of
the bugtracker.
Remove leftover mainmenu.js function that this commit should have
removed.

Profiler data upload was disabled in b9e46f386b because the data amount
was too large and because the two timing snapshots are inconclusive
without further data.
The hereby removed exposed JS functions could have been exploited by JS
mods to upload 0ad userdata to arbitrary places.

The performance data upload feature can be redesigned, implemented
without JS exposure, with a more transparent privacy policy (refs
#5257).

Differential Revision: https://code.wildfiregames.com/D1597
Performance upload feature removal accepted by: Vladislav
This was SVN commit r21858.
2018-08-05 15:18:00 +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
417c84870c Actually remove trailing tabs from source/.
This was SVN commit r18991.
2016-11-23 14:09:58 +00:00
6149dd3841 Actually remove trailing whitespace for non-header files as well.
This was SVN commit r18989.
2016-11-23 13:02:58 +00:00
a07add11c6 Some range-based for loops and some style cleanup.
This was SVN commit r16888.
2015-07-29 01:07:23 +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
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
49e2ecea63 Automatically convert all CLogger format strings from wchar_t* to char*.
Done with:

  ag -ls 'LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR)' source | xargs sed
-i 's/LOG\(MESSAGE\|MESSAGERENDER\|WARNING\|ERROR\)(L/LOG\1(/g'

This was SVN commit r16183.
2015-01-22 20:31:30 +00:00
28bdd8540f Quite a lot of stack rooting related changes.
Changes GetProperty, SetProperty and HasProperty and a few other
functions to take handles. The conversions to CScriptVal or
CScriptValRooted at some places should be removed in the future. I've
done that to avoid an even larger patch.

Refs #2415
Refs #2462

This was SVN commit r15568.
2014-07-26 22:33:16 +00:00
701508922f Use CStrIntern for font names to reduce lookup cost
This was SVN commit r14020.
2013-10-18 16:15:42 +00:00
5778484a77 Refactor text renderer
Replace unifont with CFont and CFontManager, since the h_mgr interface
was
needlessly inconvenient.

Load the font textures through CTextureManager, to support dynamic
reloading (e.g. when resetting GL state - see #741).

Add CFontMetrics as a convenient wrapper for code that just wants to
measure text.

Fixes #1117.

This was SVN commit r14016.
2013-10-18 15:53:07 +00:00
994ebd9836 Add a list of statically-constructed CStrIntern strings
Switch all the constant strings in graphics code to use the new
variables.
This avoids the cost of instantiating CStrInterns at runtime every
frame.

This was SVN commit r13906.
2013-09-29 13:19:52 +00:00
75a23856cf Fix some static analysis warnings
This was SVN commit r13101.
2013-01-21 20:33:25 +00:00
dc715fe57f Remove some unused includes
This was SVN commit r11250.
2012-03-05 16:15:07 +00:00
c888c00377 Avoid unnecessary use of printf in text renderer.
This was SVN commit r11154.
2012-02-25 17:14:47 +00:00
832a51da80 GLSL text support
This was SVN commit r11080.
2012-02-15 21:53:13 +00:00
531b40578a More GLES compatibility.
Add config option to disable hardware cursors on Windows.

This was SVN commit r11053.
2012-02-12 20:45:31 +00:00
db85833655 More GLES compatibility.
Move more rendering code to shader API.

This was SVN commit r11050.
2012-02-12 13:20:49 +00:00
3fab2729b5 Partial SDL2 compatibility
This was SVN commit r11033.
2012-02-06 22:47:35 +00:00
cc5a0fba4e Use shader API for GUI text.
Flip GUI quads so we don't have to disable back-face culling.

This was SVN commit r10989.
2012-01-30 00:27:23 +00:00
893cb2668e Renames our sdl.h to libsdl.h, to avoid case sensitivity errors when it includes SDL.h.
This was SVN commit r10904.
2012-01-12 23:32:27 +00:00
cfb79c3062 # Add GPU performance profiling support.
Add some profiler region attributes.
Render events in profile visualiser.
Change profiler from GPL to MIT.

This was SVN commit r10492.
2011-11-09 13:09:01 +00:00
09a02c96d5 Add initial code annotations for the new profiling tool
This was SVN commit r10466.
2011-11-04 01:35:50 +00:00
20ebb2b829 Fix incorrect string type in log message on non-Windows
This was SVN commit r9790.
2011-07-09 18:41:58 +00:00
74f849ad0b Adds message when profiler snapshot is first saved (Shift+F11)
This was SVN commit r9633.
2011-06-17 23:40:13 +00:00
dcd192cb60 refactor path interface:
- use wrapper class instead of std::wstring (reduces mixing of
strings/paths; allows safe+easy join via operator/ and convenient
case-insensitive comparison via operator==, avoids NativePathFromString,
similar to boost::filesystem)
- NativePath -> OsPath
- add hash and To/FromJSVal for Path
- add TS_ASSERT_PATH_EQUALS
- replace _wfopen_s with sys_OpenFile
- remove obsolete SortFiles/Directories

This was SVN commit r9107.
2011-03-23 13:36:20 +00:00
c0a105432e Use path types and conversions more consistently.
This was SVN commit r9094.
2011-03-21 22:59:00 +00:00
c3405e6f50 path improvements/fixes:
- replace more std::wstring with Native or VfsPath; wstring_from_utf8 ->
NativePathFromString
- replace sequences of Join(Path(), Basename+extension) with
ChangeExtension in wsdl, CacheLoader
- add Path::IsDirectory to replace .empty() / path_is_dir_sep(.back()).
also changed behavior to reflect the fact that "" is the VFS root
_directory_
- Path::Join now allows 2 identical path types (e.g. VfsPath) or one
char* literal (prevents inadvertently introducing non-safe characters).
to convert from wstring or wchar_t, use an explicit ctor (e.g.
VfsPath(wchar_t_string))

This was SVN commit r9091.
2011-03-21 19:54:08 +00:00
6d25329412 # towards locale-independent pathnames on Linux
c.f.
http://www.wildfiregames.com/forum/index.php?showtopic=14541&st=0&p=217250&#entry217250
and 2011-03-19 meeting

This was SVN commit r9090.
2011-03-21 17:53:13 +00:00
1c1564daaf Make profiler JSON output much more concise.
Right-align values in in-game profile viewer.
Add alternating row shading in profile viewer, to make it easier to
read.

This was SVN commit r9004.
2011-03-03 01:09:19 +00:00
d7a243343d Add per-turn counts to profiler, as well as per-frame.
Remove percent-of-parent and percent-of-frame timings since they're not
particularly useful.
Simplify profiler update code by using RingBuf.
Handle profiler keys via character codes rather than keysyms, to
hopefully work with different keyboard layouts.
Make console intercept all keys, to stop digits, shift-D, etc having
unexpected side-effects.
Disable console copy/paste when console is inactive.

This was SVN commit r8960.
2011-02-20 20:50:26 +00:00
f3372bf11d Add some rough performance reporting.
Make the profiler converge a bit faster.

This was SVN commit r8939.
2011-02-19 03:14:37 +00:00
5d764f1435 Run network server in a separate thread, to minimise latency.
Make some parts of logger and console thread-safe.
Simplify console: remove special commands; remove prefix for script
commands.
Remove LOG_ONCE, to simplify logger.
Change some code to use the new logger interface.
Fix OOS when revealing map.
Clean up some formatting.

This was SVN commit r8511.
2010-10-31 22:00:28 +00:00
9e499cdec5 # Fix hotkey bugs.
Simplify hotkey system to use strings consistently.
Restrict scope of GUI hotkey bindings to the associated page.
Avoid hard-coding list of hotkeys.
Clean up the code a little bit and fix some bugs.
Remove unused "!" prefix for key negation.
Fixes #567.

This was SVN commit r8444.
2010-10-23 02:37:00 +00:00
b292a32505 Add JS memory usage to profiler.
Add dumpHeaps() console function for debugging JS memory usage.
Increase default JS heap size.
Make call-time profile table appear first when toggling.
Remove some unused script functions.

This was SVN commit r7842.
2010-08-02 19:23:58 +00:00
7dca91f26b # Various changes to the text rendering system.
Rewrite font builder tool to be much simpler and to support more text
effects.
Change GUI to use new set of fonts.
Switch font textures from TGA to PNG so they're easier for the font
builder to create.
Support RGBA font textures (for e.g. stroked text).
Greatly improve text rendering performance by using vertex arrays.
Fix rendering code leaving vertex buffers bound.
Add 'clip' property to GUI text objects, to disable clipping when
rendering.
Delete part of unused console function registration system.

This was SVN commit r7595.
2010-05-30 13:42:56 +00:00
a7484933e7 wchar.h -> utf8.h (see previous change)
This was SVN commit r7341.
2010-03-01 14:55:34 +00:00
ff15c522fe implement changes suggested by Philip:
- add self-test
- allow decoding UTF8 values beyond BMP (and replace them later)
- quietly replace invalid bytes

This was SVN commit r7187.
2009-11-09 20:53:48 +00:00