Commit Graph

7312 Commits

Author SHA1 Message Date
92cbcf85e5 Rename CProgressBar numeric "caption" setting to "progress" to distinguish it from the Button, Input, Text and Tooltip "caption" setting values that are tag-formatted texts.
Remove TODO question from c4684effb6 since the class updates correctly.

Differential Revision: https://code.wildfiregames.com/D2419
Tested on: clang 9.0.0, Jenkins/gcc6, Jenkins/vs2015

This was SVN commit r23151.
2019-11-12 16:53:19 +00:00
235e238f9d Fix 34ce0f865d resetting the cursor after calling the GUI pages script "init" function, refs #539.
Reset the cursor everytime the GUI page is opened, therefore also when
hotloading.

The init function shall be able to determine a cursor, such as already
present in the loading screen.

Differential Revision: https://code.wildfiregames.com/D2417
Tested on: clang 9.0.0, Jenkins/gcc6, Jenkins/vs2015

This was SVN commit r23149.
2019-11-12 14:43:58 +00:00
6a97c59c67 Change CGUIManager::SendEventToAll to send to all GUI pages.
Notably enables processing of GuiInterface messages when dialogs are
opened.

Differential Revision: https://code.wildfiregames.com/D2408
Tested on: clang 9.0.0, Jenkins/vs2015

This was SVN commit r23138.
2019-11-06 00:30:18 +00:00
570891e362 Fix session quickload taking ownership of frozen objects by providing a clone following 003d588d13/D2302 and a report by minohaka.
Differential Revision: https://code.wildfiregames.com/D2406
Tested on: gcc 9.2.0, Jenkins

This was SVN commit r23136.
2019-11-05 14:24:24 +00:00
f7161ad5c6 Support deleting GUI Object event handlers following af9c336b43, refs #5387.
Differential Revision: https://code.wildfiregames.com/D2395
Reported by: nani
Tested on: gcc 9.2.0, Jenkins/vs2015

This was SVN commit r23103.
2019-10-28 11:35:04 +00:00
197ab42bd2 Remove catch of critical PSERROR_Scripting exceptions in the GUI that is obsolete for the intended case and wrong for the unintended case.
The catch had been introduced in 953fb41c82, seemingly to catch the case
PSERROR_Scripting_LoadFile_OpenFailed from 1e40ed1543 which was removed
in 4b1297b328, refs D2363.
The LoadGlobalScript and LoadGlobalScriptFile functions don't throw
these errors unless that JS code calls broken C++ code throwing that.
In that case catching the error and continuing like nothing happened
leads to subsequent segfaults and similarly severe errors caused by C++,
not XML.

Differential Revision: https://code.wildfiregames.com/D2366
Tested on: clang 9.0.0, gcc 9.2.0, Jenkins/vs2015
Accepted By: nani
This was SVN commit r23068.
2019-10-11 19:30:28 +00:00
a01e68a4ea Don't leak all GUI objects on name ambiguity following 5cc814759f and remove ERROR_GROUP GUI.
Delete CGUI::UpdateObjects and don't recreate the entire object
hierarchy by recursing through the existing one each time when inserting
one GUI Object.
Change CGUI::AddObject to only insert the one relevant pointer into the
map hierarchy, return success value and delete the child upon failed
insertion in the caller instead of leaking it.
Defer GUIM_LOAD and UpdateCachedSize recursion until all XML files
linked in the page XML file were loaded.
Delete related ERROR_TYPE NameAmbiguity, ObjectNeedsName, and unrelated
JSOpenFailed and in consistency with the rest, do the LOGERROR in the
scope where the error occurs.
Delete ERROR_TYPE InvalidSetting from 90f6641c1d unused following
85a622b13a, 1a49ccb294, ERROR_TYPE OperationNeedsGUIObject from
90f6641c1d unused following d3e56f0f57, see also e1014aad3b, refs #128.

This was SVN commit r23067.
2019-10-11 16:20:50 +00:00
8cd9d402fe Correct button hovering following 8190293f8b / D2325, clarify difference between IsMouseOver and IsMouseHovering following 5122b0f906.
Differential Revision: https://code.wildfiregames.com/D2354
Tested on: clang 8.0.1, Jenkins/vs2015

This was SVN commit r23054.
2019-10-05 09:58:31 +00:00
d7ea078583 Removes unused variables after 7f38bef8e1 and 75d9c6293b. Reported by elexis.
This was SVN commit r23046.
2019-10-04 22:06:52 +00:00
e2f0e409f0 Adds containers serialization tests, std::set serialization and movement semantics
Reviewed By: elexis
Tested By: elexis, Freagarach
Differential Revision: https://code.wildfiregames.com/D2352
This was SVN commit r23044.
2019-10-04 21:30:52 +00:00
75d9c6293b Adds projection type to CCamera to control usages of projection dependent properties.
Commented By: elexis
Differential Revision: https://code.wildfiregames.com/D2351
This was SVN commit r23036.
2019-10-03 18:51:40 +00:00
8d2b143cb8 Cleanup Camera related code and uses constant references where possible, fixes #5408.
Patch By: shh
Reviewed By: wraitii
Tested By: Angen
Commented By: Stan, Itms, historic_bruno
Differential Revision: https://code.wildfiregames.com/D1784
This was SVN commit r23034.
2019-10-03 13:20:56 +00:00
a19b14aeb7 Cleanup Camera related code and uses constant references where possible.
Commented By: elexis
Differential Revision: https://code.wildfiregames.com/D2350
This was SVN commit r23033.
2019-10-03 12:58:47 +00:00
7f38bef8e1 Splits Camera control from CGameView to separate file.
Commented By: elexis, Stan
Differential Revision: https://code.wildfiregames.com/D2347
This was SVN commit r23031.
2019-10-02 20:55:43 +00:00
28e94c0d96 Cleanup CCmpRallyPointRenderer
Replace std::deque by std::vector
Replace some casts by cpp casts
Move the class and struct declaration to a separate file for clarity.
Fixes db864f10c3 by removing offending function
Refs #5288
Refs D1681

Reviewed by: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D1682
This was SVN commit r23029.
2019-10-02 15:01:46 +00:00
6db0f91823 Sort GUI Object types, GUI Object bases and GUI Setting value types into three new folders.
Differential Revision: https://code.wildfiregames.com/D2345
Tested on: gcc 9.1.0
Comments By: Vladislav
This was SVN commit r23028.
2019-10-02 09:44:00 +00:00
1cf6c6b63c Moves CSmoothedValue to separate file.
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2346
This was SVN commit r23026.
2019-10-01 22:42:54 +00:00
45a18c652d Removes unused methods and hides private member.
Commented By: elexis
Differential Revision: https://code.wildfiregames.com/D2342
This was SVN commit r23025.
2019-10-01 21:11:29 +00:00
32d6d07eda Rename CClientArea to CGUISize, GUIbase.h to CGUISize.h, avoid temporary instances and default value and error duplication.
The name is in accordance with its JS classname, member names and
setting names.

Differential Revision: https://code.wildfiregames.com/D2341
Tested on: clang 8.0.1, Jenkins/vs2015

This was SVN commit r23023.
2019-10-01 15:06:13 +00:00
07cc1ba34c Move GUIbase structs and enums to separate files.
Differential Revision: https://code.wildfiregames.com/D2340
Tested on: clang 8.0.1, Jenkins

This was SVN commit r23022.
2019-10-01 12:46:55 +00:00
8190293f8b Remove virtual inheritance from the codebase, refs 6b51d71c85, e21ebb37f5 e326ebae46.
Remove workaround in 3d07327837 / D2136, the pointer from IGUIObject to
IGUITextOwner that avoided the dynamic_cast.
Have the GUIObject implementing class take responsibility of calling the
virtual methods in the base classes.
Leaves the code in a clean state that can serve as an example for new
GUI object classes, such as D1346, refs #4683.

Differential Revision: https://code.wildfiregames.com/D2325
Comments By: Vladislav on IRC 2019-07-30, 2019-08-22, 2019-09-20-23
Tested on: clang 8.0.1, Jenkins

This was SVN commit r23020.
2019-09-30 14:08:14 +00:00
1679510bb8 Resolve Loader memory leak from 1f1642bfe3.
Use C++11 featured shared_ptr to avoid conditional deletion in multiple
locations.
Drops C compatibility(?) of Loader.h.

Differential Revision: https://code.wildfiregames.com/D2331
Tested on: clang 8.0.1., Jenkins
Comments on IRC #wfg 2005-05-07
Refs 77d3c5d0b5, 5e3b0f06ec, f19d8dafee.

This was SVN commit r23019.
2019-09-30 08:49:00 +00:00
218399bf3d Rename JSInterface_GUITypes to JSInterface_GUISize, refs 8734efca94, 9be8a560a9.
Rename init to RegisterScriptClass.

Differential Revision: https://code.wildfiregames.com/D2339
Tested on: clang 8.0.1., Jenkins/vs2015

This was SVN commit r23018.
2019-09-30 08:19:56 +00:00
52b7fd5cd9 Remove redundant IGUITextOwner::AddText IGUIObject/this argument.
Differential Revision: https://code.wildfiregames.com/D2333
Tested on: clang 8.0.1., Jenkins/vs2015

This was SVN commit r23009.
2019-09-28 11:46:06 +00:00
b097f38a79 Remove little IGUIButtonBehavior::DrawButton duplication.
Differential Revision: https://code.wildfiregames.com/D2332
Tested on: clang 8.0.1., gcc 9.1.0, Jenkins/vs2015

This was SVN commit r23008.
2019-09-28 11:33:58 +00:00
813fc38420 Fix alphabetic sorting induced syntax error in previous, a33fd55e81/D2313, reported by go2die.
This was SVN commit r23006.
2019-09-27 14:08:00 +00:00
a33fd55e81 Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.

Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 12:49:59 +00:00
7790fd7d29 Removes duplication of Clamp function.
Reviewed By: wraitii
Commented By: Stan
Differential Revision: https://code.wildfiregames.com/D1763
This was SVN commit r23002.
2019-09-26 21:14:21 +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
0817d5d715 Always inform clients why the server chose to disconnect them, i.e. stop using NDR_UNKNOWN as a disconnect reason when the reason is known and add a LOGWARNING for future authors.
Differential Revision: https://code.wildfiregames.com/D1561
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22996.
2019-09-26 11:36:03 +00:00
00b58fc2ed Fix previous, don't save replay metadata if a multiplayer gamesetup page was opened and closed, refs 35408e7e7e / D2197, refs #5565.
This was SVN commit r22992.
2019-09-25 16:41:14 +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
92ad6a61fa Fix OOS introduced by pathfinder threading preparation diff d592bf9cb6
Following d592bf9cb6, paths were computed at the end of turn N, and then
messages were sent at the beginning of turn N+1. However, the path
requests were removed at the end of turn N and so weren't serialised,
and neither were computed paths. This meant rejoiners would OOS when the
game was serialised with pending path results.

To fix this in preparation for threading, the architecture needs to
change slightly so that requests are kept and serialised correctly, and
rejoiners can compute the paths after deserialisation, in order to send
the messages at the beginning of turn N+1.

Fixes #5604

Reported By: elexis
Differential Revision: https://code.wildfiregames.com/D2317
This was SVN commit r22979.
2019-09-23 06:38:16 +00:00
b9d413852b Cleanup GUI includes, whitespace, map iterators, nullptr.
Remove TODO comment about m_Children deletion from e21ebb37f5, refs
e05f939fab / D2311.

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

This was SVN commit r22976.
2019-09-22 23:28:25 +00:00
e67f364887 Warn if the derived class and the base class have the same AddSetting call instead of silently ignoring it.
Enabled by f69261d37b (refs d412b2010b / D2314, 7bb0f2ea69 / D2318).
Helps structuring the GUI so that AddSetting and GetSetting are in the
same file, which defragments code and may allow for future optimizations
(setting values as class members for Draw calls), refs D2313.

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

This was SVN commit r22975.
2019-09-22 22:49:20 +00:00
987b36d53c Do not send Reflection and Refraction matrices to shader when not needed
Patch By: Angen
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1954
This was SVN commit r22971.
2019-09-22 14:56:22 +00:00
077c4f2576 Adds a "properties"-property to resources and let mods be able to prevent resources from being bartered, traded and/or tributed.
Patch By: Freagarach
Comments By: elexis, Stan`, Nescio
Reviewed By: wraitii, Angen
Fixes #4370

Differential Revision: https://code.wildfiregames.com/D1846
This was SVN commit r22970.
2019-09-22 14:53:47 +00:00
7bb0f2ea69 Defragment IGUIButtonBehavior Settings.
Moves the AddSetting sound calls from CButton and CCheckbox to
IGUIButtonBehavior, since the latter is the only class to use them.
Moves ChooseColor from IGUIButtonBehavior to CButton, since that's the
only class to use it and the only class registering the dependent
Settings following b1422137e5 (refs d412b2010b / D2314)

Initialize m_PressedRight in the constructor to prevent undefined
behavior in possible future code following 0d204037b6, refs #1028.
Remove unused soundPath variable following 0e26503cc6 / D2209.

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

This was SVN commit r22969.
2019-09-22 14:53:27 +00:00
d1bcce55db Improve js glue code in D1839/61e3f1ec0d (hotkey state fix) and deal with rebase leftovers.
The code could be improved by using more modern code.

Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2295
This was SVN commit r22963.
2019-09-22 07:38:13 +00:00
f69261d37b Remove AddSetting<CStrW>("tooltip") and AddSetting<CStr>("tooltip_style") calls redundant with the ones in the IGUIObject base constructor.
If all redundant calls are removed, the code will be able to warn about
them.

Tested on: clang 8.0.1

This was SVN commit r22958.
2019-09-21 16:13:18 +00:00
d412b2010b Delete unused CCheckbox text setting remains following b1422137e5, refs 0f807c643a.
Differential Revision: https://code.wildfiregames.com/D2314
Tested on: clang 8.0.1., Jenkins

This was SVN commit r22952.
2019-09-21 03:11:18 +00:00
aa72791b69 Fixes compilation errors about missed include and unused argument introduced in c17e7ee92f.
Patch By: elexis
Reported By: elexis
This was SVN commit r22950.
2019-09-20 19:44:58 +00:00
734d21464b Fix missing JSAutoRequest before JS_ReportError in various commits.
Differential Revision: https://code.wildfiregames.com/D2256
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22949.
2019-09-20 19:18:07 +00:00
e05f939fab Delete empty IGUIObject::Destroy function and MEGA TODO from 5122b0f906, e21ebb37f5.
None of the GUI object types implemented in the past two decades owns
children, only the CGUI page.

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

This was SVN commit r22943.
2019-09-20 15:25:13 +00:00
1bc6d778bb Delete GUI.h umbrella include following 8d0cb1b954.
Differential Revision: https://code.wildfiregames.com/D2304
Tested on: clang 8.0.1., VS2015, Jenkins
Comments By: Vladislav, Angen, Stan
Tested by: Angen
This was SVN commit r22941.
2019-09-20 13:11:18 +00:00
8f7729bfdb Fixes values of clip planes in PostProcManager.
Reviewed By: wraitii
Commented By: elexis
Differential Revision: https://code.wildfiregames.com/D2196
This was SVN commit r22940.
2019-09-20 07:54:44 +00:00
c17e7ee92f Adds a helper function to pick entities with a given component and a given filter on screen.
Reviewed By: wraitii
Commented By: Stan, elexis
Differential Revision: https://code.wildfiregames.com/D2207
This was SVN commit r22939.
2019-09-20 07:45:55 +00:00
a936cc618a Move CGUIDummyObject class used for empty GUI objects to a separate file, and put the according CGUI page base object on the stack.
Differential Revision: https://code.wildfiregames.com/D2206
Tested on: clang 8.0.1., Jenkins

This was SVN commit r22931.
2019-09-18 20:51:45 +00:00
7985ea4b8e Removes usages of duplication of Clamp function in simulation and atlas. Refs D1763.
This was SVN commit r22927.
2019-09-18 15:02:36 +00:00
f1de8eb4ba Removes usages of duplication of Clamp function in gui, ps and renderer. Refs D1763.
This was SVN commit r22926.
2019-09-18 14:44:31 +00:00
050f1dc8df Removes usages of duplication of Clamp function in graphics. Refs D1763.
This was SVN commit r22925.
2019-09-18 08:34:36 +00:00
003d588d13 Happy savegame hack removal following e0ea53a8ee, refs #2030.
Simply pass the JS value to the Save functions instead of letting those
obtain the data later from the topmost GUI page.
The JS hack incidence appears to be unused since 4b1297b328.

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

This was SVN commit r22922.
2019-09-18 00:17:56 +00:00
93fed19c6a Reliably report and reject invalid XML files following a18fbd12ec, refs #245, fixes #5222.
Don't write XMB files for XML files that failed the validation,
otherwise the XML validation error will not be reported on consecutive
program starts anymore (as the XMB is loaded, skipping validation).
This had resulted in invalid XML  going unnoticed and committed in
credentials.xml in 80dbd1f2a3.

Differential Revision: https://code.wildfiregames.com/D1574
Reported by: gameboy
Comments By: bb
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22921.
2019-09-17 23:00:36 +00:00
41475093b0 Fix struc tree / civ info hotkeys following rebase error in adf448db4d / D2240 and don't trigger global hotkey handlers upon release following f192d4a2fa / D2260.
Differential Revision: https://code.wildfiregames.com/D2273
Tested on: clang 8.0.1., Jenkins
Tested by: Nescio
This was SVN commit r22920.
2019-09-17 22:42:50 +00:00
da958bf0e4 Fix wrong GlooxScriptConversions include in 9023f4bebb / D2264 triggering VS2015 build warning but no clang build warning, refs #5596.
Differential Revision: https://code.wildfiregames.com/D2298
Tested on: clang 8.0.1., Jenkins

This was SVN commit r22919.
2019-09-17 20:39:09 +00:00
a3d8807833 Fix 61e3f1ec0d on Windows.
Patch By: Angen
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2299
This was SVN commit r22917.
2019-09-17 19:27:38 +00:00
d468535df3 Split NetFileTransfer message parsing into one function per case, refs #5212.
Avoid redundant map lookups by caching the iterator.
Remove c-style casts by using type specific printf parameters, and
static_cast elsewhere.
Use references while at it, and typedef -> using.

Differential Revision: https://code.wildfiregames.com/D1567
Comments by: Vladislav
Tested on: clang 8.0.1, gcc 9.1.0

This was SVN commit r22916.
2019-09-17 14:18:46 +00:00
4d4bf579b2 Report and tolerate XML GUI object setting errors when parsing XML attribute strings as values for settings that don't exist on the GUI object.
Following e326ebae46, 80b1876b77, d6db5a466d, ... the XML errors were
silently ignored.
Following 1a49ccb294 it led to a crash (m_Setting access for an item
that does not exist).

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

This was SVN commit r22911.
2019-09-16 16:13:25 +00:00
61e3f1ec0d Fix hotkey events synching with hotkey state.
This is a semi-revert of 78bc56f33e and a correct fix for #3194.

The core issue is that the GUI handler must come behore the hotkey
handler, otherwise typing in boxes can set off hotkeys, and the hotkey
handler is repsonsible for updating the hotkey state.
Thus the GUI handler never has an up-to-date hotkey state, since that's
done later. 78bc56f33e fixed that by calling HotkeyInputHandler
manually, but that was still broken in some (unused) cases and was hacky
(indeed, it even looked hacky as noted by elexis).

The simplest fix is to split the 'hotkey creator' handler from the
'hotkey state change' handler, and run the 'hotkey state change handler'
before any other handler. Thus the gui handler remains in front of the
'hotkey creator' handler, but it has a correct hotkey state at any time.

Differential Revision: https://code.wildfiregames.com/D1839
This was SVN commit r22909.
2019-09-15 12:16:28 +00:00
c6e5c83b6d Workaround differences between libc and libstd string stream parsing of float/doubles.
libc and libstd differ on how they parse strings. This has a remote
chance of breaking mods and 0 A.D. code, and it broke tests on MacOS.

Add a workaround to ensure they are consistent.

Comments by: vladislavbelov
Fixes #2780

Differential Revision: https://code.wildfiregames.com/D1988
This was SVN commit r22908.
2019-09-15 12:02:26 +00:00
98b8775cd9 Fix glooxwrapper::Message::when() memory leak in f2c76cc75d, refs #3156.
Differential Revision: https://code.wildfiregames.com/D2291
Tested on: clang 8.0.1

This was SVN commit r22903.
2019-09-15 10:28:23 +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
89e511def9 Allow JS GUI pages to find out if the game is running.
Differential Revision: https://code.wildfiregames.com/D2289
Tested on: clang 8.0.1.

This was SVN commit r22900.
2019-09-14 15:33:46 +00:00
cab920696c Implement glooxwrapper::MUCRoom argument for muc event handlers.
I.e. don't dereference NULL if the user of the glooxwrapper library
reads from the provided room argument.
A step towards being able to use XmppClient with multiple rooms.

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

This was SVN commit r22898.
2019-09-13 15:24:44 +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
cbc04ba83b Use all three color channels when loading heightmaps following 204b04f2d4, refs #5018.
Removes wrong debug leftover line from 204b04f2d4 and unneeded clamp
from c9abf6f68c.

Differential Revision: https://code.wildfiregames.com/D1816
Patch By: Angen
Comments By: Vladislav
This was SVN commit r22892.
2019-09-12 19:30:43 +00:00
4c454f3eee Fix missing wstring_from_utf8 for multi-user-chat messages and translated strings following 9023f4bebb / D2264.
The commit introduced support for arbitrary lobby CreateGUIMessage
JS::Value arguments but didn't transfer wstring_from_utf8 appropriately.
Instead of enlengthening the code by reintroducing utf8_from_wstring
everyhwere, shorten the code and specialize ToJSVal for
glooxwrapper::string and gloox enums.

Avoid string copies for XmppClient getters, refs D1668:
Change GetPresence() and GetRole() to return the pointer to the string
literal instead of copy constructing a std::string each call.
Don't reintroduce the unneeded utf8_from_wstring conversions for the
untranslatable ASCII identifiers returned by GetPresence() and
GetRole().
Change GetSubject() to return a const ref to the member instead of copy
assigning the std::string to an output value.
Change m_Subject to std::wstring to avoid constructing a copy using
wstring_from_utf8 each GetSubject() call.
Change gloox enum to translatable string functions to be static, so as
to use them in the new ToJSVal functions (enabled by not calling
CertificateErrorToString from ConnectionErrorToString anyymore in
92fc34c87c/D2274).

Avoid per-player string copies in m_PlayerMap:
Change m_PlayerMap value type from std::vector<std::string> to a new
PlayerMap struct with named members for readability.
Use gloox enums as PlayerMap values to avoid constructing (performance)
and storing (memory footprint) std::strings.
The JS String is created from the pointer to the ASCII string literal
without intermediaries.
Use glooxwrapper::string for nickname and m_Rating since it's the data
source type received in relevant places, but that might be improved for
performance with std::wstring.

Construct map values in place where possible and post error instead of
silently inserting if an existing value is to be modified.
Avoid repeated std::map lookups on string keys by caching the
PlayerMap::iterator where available.

Remove some glooxwrapper::string to_string() calls redundant with its
operator<< and improve DbgXMPP gloox enum output.
Transfer rating too upon nickchange.

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

This was SVN commit r22891.
2019-09-12 17:23:33 +00:00
28aa7c20e4 Fix lobby playerlist rebuild following presence update message removal in 6bf74902a7/D2265.
Update the list when the data it is built from changes, not only for
presence changes.

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

This was SVN commit r22888.
2019-09-11 11:51:34 +00:00
f77a3e289c Fix historic lobby kick messages following arbitrary CreateGUIMessage arguments in 9023f4bebb/D2264.
Perform the freezing for historic messages equally.

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

This was SVN commit r22887.
2019-09-11 10:15:13 +00:00
2233a76e2a Fix units sometimes turning around when fleeing (introduced by D1987/99a341f379)
D1987/99a341f379 introduced logic to predict the target movement, which
fixed unit chasing. However, sometimes fleeing units would then predict
that their target will end up in front of them, so they turned around
towards the attacker.

This is fixed by not anticipating the position when it would cause the
vector towards to target to change direction.

Reported By: Freagarach
Tested By: Freagarach
Fixes #5541

Differential Revision: https://code.wildfiregames.com/D2275
This was SVN commit r22885.
2019-09-10 18:11:07 +00:00
92fc34c87c Pass XmppClient CertificateErrorToString independent of ConnectionErrorToString to JS using D2264 / 9023f4bebb, refs #4482.
This also allows making the enum to string functions static, refs D2271.

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

This was SVN commit r22880.
2019-09-09 21:26:58 +00:00
158ba53a46 Fix missing XmppClient m_certStatus and m_PresenceUpdate member initialization following 0e2adda813 and 6bf74902a7.
This might explain unexpected TLS certificate error strings upon failed
TLS handshake, refs #4705.
Might or might not fix a conditional valgrind conditional jump depending
on uninitialized value error reported in P170 for the XmppClient
constructor (inconsistent test results).

Differential Revision: https://code.wildfiregames.com/D2278
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins

This was SVN commit r22879.
2019-09-09 20:50:17 +00:00
fcc7a831bb Fix issues with MakeGoalReachable when the goal wasn't reachable following D1882/208fc30ddd
This fixes the issue and adds a regression test.

Differential Revision: https://code.wildfiregames.com/D2277
This was SVN commit r22878.
2019-09-09 18:57:59 +00:00
9cc8a579f5 Silence uninitialized variable warnings on MakeGoalReachable and FindNearestNavcellInRegions in 208fc30ddd
These variables might be used uninitialised in very odd cases that don't
happen in svn.

Reported By: elexis
Differential Revision: https://code.wildfiregames.com/D2250
This was SVN commit r22877.
2019-09-09 18:56:49 +00:00
ee726a155c Translate lobby TLS certificate error strings following 0e2adda813 and string freeze lift, refs #4705.
Differential Revision: https://code.wildfiregames.com/D2272
This was SVN commit r22875.
2019-09-09 14:33:30 +00:00
bfc34f3f58 Fix previous (invalid Freeze 508da732af).
This was SVN commit r22868.
2019-09-07 17:04:04 +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
43bbd7d671 Check only that the destruction queue contains no non-local entity when serializing the game state.
Local entities being in the destruction queue when serialising is not an
issue since those should not affect the simulation anyways. This stops
the game from crashing in some rare situations.

Fixes #4616

Differential Revision: https://code.wildfiregames.com/D1738
This was SVN commit r22865.
2019-09-07 14:41:53 +00:00
de050ef7e2 Remove some unused Profiler.h and CLogger.h includes.
NativeWrapperDefns.h from 4e87fef3da, found in audit of 7c21a0cf8e.

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

This was SVN commit r22863.
2019-09-07 13:35:45 +00:00
b1de59de66 Fix algorithmic error in 9903fd8a6c (waves computation speedup), and delete unused code.
9903fd8a6c introduced a much faster (for a little precision cost)
algorithm to compute distance to shore. However a condition was
incorrectly inverted, which made the algorithm return less-than-sensible
results in many situations.

Further, there was some unused code left behind which is now removed.

Fixes #5580

Reported by: nani (shore bug), elexis (unused code)
Differential Revision: https://code.wildfiregames.com/D2249
This was SVN commit r22862.
2019-09-07 08:50:55 +00:00
10f805fcf4 Fix wrong "player is not a moderator anymore" lobby chat message following initial implementation in 76bc9b579a/D339, fixes #4877.
It needs to test against the historic role and not the current role,
similar to 8b437a0b1c, refs #3386.
Implements the third GUI message property using the arbitrary lobby GUI
message patch in 9023f4bebb/D2264, refs #4482, 6bf74902a7/D2265.

Differential Revision: https://code.wildfiregames.com/D2266
Tested on: clang 8.0.1

This was SVN commit r22859.
2019-09-06 16:56:43 +00:00
9023f4bebb Support creating lobby GUI messages with arbitrary arguments instead of forcing every message type into the same struct type, refs #4877 / 76bc9b579a / D339.
Creates the GUI messages directly as JS::Values and removes the
intermediary rigid struct.
Implementation similar to ScriptInterface::CreateObject from D2080.

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

This was SVN commit r22856.
2019-09-06 05:14:20 +00:00
6bf74902a7 Drop lobby presence GUI messages altogether for better performance and less code complexity.
They were only used to determine whether the playerlist should be
rebuilt, which can be achieved by a boolean member.
So this patch is removing unnecessary indirection from the original
solution in 8b437a0b1c and the reduction in 16b976fc35, refs #3386.
In particular the LobbyClearPresenceUpdates call was ugly and one doesnt
need hundreds of messages with data on it each if one only wants to know
if there was one.
Makes past (e8dfde9ba6) and future (D2264) patches less complex, refs
#4877.

Differential Revision: https://code.wildfiregames.com/D2265
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins

This was SVN commit r22855.
2019-09-06 02:53:22 +00:00
afaa4417e4 Add ScriptInterface::AssignOrToJSVal<JS::Heap<JS::Value> > to support ScriptInterface::SetGlobal, SetProperty, CreateObject with JS::Heap values.
Differential Revision: https://code.wildfiregames.com/D2263
Tested on: gcc 9.1.0, Jenkins
Refs D2264

This was SVN commit r22853.
2019-09-05 16:45:16 +00:00
f192d4a2fa Support assigning functions to hotkeys from the JS GUI without involving a GUI object.
Allows developers and modders to register and unregister hotkeys without
having to specify, change or overwrite XML files.
Also allows implementing the main menu GUI page with only GUI objects
for one submenu, refs #5387 / D2240.

Differential Revision: https://code.wildfiregames.com/D2260
Idea by nani in D2257.

This was SVN commit r22851.
2019-09-05 10:42:16 +00:00
d5c1fd09a4 Add ToJSVal<CRect> to make the conversion reusable, remove unused PSERROR_Scripting_ConversionFailed and dead catch.
Avoids the CRect copy or stops relying on optimization to avoid the
copy.
Split from D2142.

Differential Revision: https://code.wildfiregames.com/D2259
Tested on: gcc 9.1.0, Jenkins

This was SVN commit r22847.
2019-09-04 16:15:37 +00:00
c25ab670e6 Don't crash if a JS GUI author calls Engine.PopGuiPage too often.
Differential Revision: https://code.wildfiregames.com/D2255
Tested On: clang 8.0.1, Jenkins
Comments By: Stan
This was SVN commit r22846.
2019-09-04 15:45:48 +00:00
33af6da5e1 Implement JS support for GUI object "hotkey" setting missing from 6d8b9e33ef, refs #567, #2604, 9e499cdec5.
Allows JS GUI to assign hotkeys to GUI objects from JS instead of XML.

Differential Revision: https://code.wildfiregames.com/D2257
Comments By: nani
Tested By: nani, Jenkins
Tested on: clang, VS2015

This was SVN commit r22845.
2019-09-04 15:29:36 +00:00
67795d4451 Fix duplication and clang warning in unreachable gathering target fix 30dcd696eb / D2120
The function was put in an anonymous namespace to avoid linking errors
should another one be defined elsewhere.

Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2243
This was SVN commit r22825.
2019-09-01 14:10:02 +00:00
208fc30ddd Optimise MakeGoalReachable and FindNearestNavcellInRegions (D53 outtake)
By leveraging custom ordering in std::set, MakeGoalReachable and
FindNearestNavcellInRegions can be optimised and the code simplified.

Differential Revision: https://code.wildfiregames.com/D1882
This was SVN commit r22817.
2019-09-01 08:59:17 +00:00
30dcd696eb Improve gathering behaviour when a target is not reachable
Units can be stuck in gather states when the target ought to be
collectable from, but it's actually unreachable.

A new FINDINGNEWTARGET intermediate state for GATHER will try and find a
new, different target to collect from. This should generally improve the
behaviour (perfect reachability checks would be required to completely
fix it).
Use this also when the target is knowably unreachable / uncollectible.

Fixes #5529

Differential Revision: https://code.wildfiregames.com/D2120
This was SVN commit r22816.
2019-09-01 07:35:32 +00:00
9e41ff39fc Unit Motion - make sure units don't get stuck in the special long-path computation step.
In some rare cases, units could be stuck in the special state of 3
failed path computations, making them always compute long paths instead
of trying short paths again. This can happen when they compute a long
path successfully, but the unit cannot actually move as it gets
obstructed right away.
Make sure this state is never kept for more than one turn to fix this
problem.

Refs #5569 (probable fix but kept open for further investigating).

Differential Revision: https://code.wildfiregames.com/D2239
This was SVN commit r22815.
2019-09-01 07:31:21 +00:00
9c6039e4fe Solemnly delete class GUI and rename GUIUtil.h to CGUISetting.h.
Finishes GUIutil rewrite and fixes #5575.

Differential Revision: https://code.wildfiregames.com/D2233
Test on: clang 8.0.1, Jenkins

This was SVN commit r22801.
2019-08-29 09:07:29 +00:00
1a49ccb294 Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.

Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.

Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts

This was SVN commit r22796.
2019-08-28 11:21:11 +00:00
be963ec9b7 Delete 27 invalid style settings and add LOGWARNING to inform future authors.
Unify the two IGUIObject::LoadStyle functions and remove CGUI argument
that is always identical to the member.

Differential Revision: https://code.wildfiregames.com/D2232
Tested on: gcc 9.1.0., clang 8.0.1, Jenkins

This was SVN commit r22792.
2019-08-27 16:03:24 +00:00
0a6b650189 Delete SGUIMessage GUIM_SETTINGS_UPDATED broadcasts redundant with the broadcast initiated from SetSetting from e21ebb37f5.
659a9ea57a introduced the call rightfully in ShowTooltip since
CTooltip::SetupText() depends on the just changed _mousepos setting.
But then 0382cdd9b1 moved that _mousepos SetSetting call, resulting in
the message becoming redundant; and it inserted the second redundant
message in HideTooltip.

These were the only redundant SGUIMessage HandleMessage calls.

This was SVN commit r22790.
2019-08-26 23:39:16 +00:00
92b6cdfeab Move static GUI<>::GetSetting operating on IGUIObject member to a IGUIObject member function, grouping it with SettingExists and AddSetting.
Differential Revision: https://code.wildfiregames.com/D2230
Tested on: gcc 9.1.0, Jenkins

This was SVN commit r22789.
2019-08-26 12:25:07 +00:00
719f2d7967 Remove default CGame constructor values to make the code less error-prone, use CRenderer::IsInitialised() to test if the CGame should be rendered to remove indirection/proxies, making the code easier to read.
1c0536bf08 introduced a disableGraphics bool with a default value and
relied on the default being reasonable except for the few needed cases.
be93b31411 introduced the replayLog argument with a default value and
relied on the default being reasonable except for the few needed cases.
5747619c39 fixed a bug in that commit because the default value hadn't
actually been considered to be correct for all CGame constructor calls
and was wrong for two.

By requiring callers to specify the value, authors are forced to
establish thought which value is the correct one, as opposed to hoping
that a default value will be good by default.
As you can see in the diff, it also makes it easier to compare what
values changed if they are always defined in the caller.

Use CRenderer::IsInitialised() to determine if this is a non-visual
CGame,
for the purpose of removing less transparent proxy functions that are
unneeded as long as there are about 30 other calls testing for
CRenderer::IsInitialised() to determine if the Game should be rendered.

Supersedes:
* CGame constructor argument bool disableGraphics from 1c0536bf08.
* CGame::IsGraphicsDisabled() proxy from a533fff883 to the proxy from
1c0536bf08 and two local nonVisual = args.Has("autostart-nonvisual")
variables in GameSetup.cpp from a533fff883.

Call the Renderer destructor instead of calling delete on the
non-pointer (SAFE_DELETE would not be supported for instance).

Started as a preparation for D2197, but actually independent.

Differential Revision: https://code.wildfiregames.com/D2211
This was SVN commit r22785.
2019-08-25 11:02:55 +00:00
4919a6185e Remove unused GUIUtil functions, unused GUI includes and some tails in GUIUtil.
HasSetting from 3dfa23cd25 is actually redundant with
IGUIObject::SettingExists.
GetSettingPointer from 8f4f8e240f is superseded by GetSetting reference
following 3dfa23cd25 and 040624acff.
Deregister copying SetSetting variants for CStr and CStrW following copy
removal in 040624acff.
The default template <typename T=int> from c2a71e41bf can be removed
following FallBackSprite/FallBackColor removal in 9985fcf5bd and
RecurseObject unification in d4d5187c9d.
Delete all unused GUI includes, refs D1478.
Remove GUIUtil friend class following something.

Differential Revision: https://code.wildfiregames.com/D2225
Tested on: gcc 9.1.0, Jenkins

This was SVN commit r22779.
2019-08-25 08:57:36 +00:00
b197df5ee6 Fix valgrind conditional jump depending on uninitialised value warning in CGUIManager::HandleEvent from 7c2e9027c2.
The warning seems to be a false positive and happens with clang but not
gcc.

Differential Revision: https://code.wildfiregames.com/D2223
Reviewed By: Vladislav
This was SVN commit r22777.
2019-08-24 22:25:26 +00:00
55efe4a735 Fix L10n::FormatMillisecondsIntoDateString memory leak following c92e74138a, refs a74fcdcb35, #3350, #4418, #2938.
createDefault returns a new pointer to be deleted, getGMT returned a
pointer to an icu variable not to be deleted.

Differential Revision: https://code.wildfiregames.com/D2220
Reviewed By: Vladislav
This was SVN commit r22773.
2019-08-24 17:33:29 +00:00
62dd922bc0 pthread -> std::thread (5/7) - Replace sdl semaphore with condition variable
This removes a dependency on the SDL_Thread header.

Differential Revision: https://code.wildfiregames.com/D1921
This was SVN commit r22772.
2019-08-24 11:26:58 +00:00
e16c4c4800 Add a system component to handle stat modifiers, make technologies and auras use this common interface.
The ModifiersManager system component provides an interface to add and
remove modifiers, and get modified stats.
The goal is to merge all the different stat-modifying systems 0 A.D. has
implemented over the years.
This commit makes technologies and auras use ModifiersManager. Some
cheats and AI bonuses also have a similar stat-modifying effect that
have not yet been updated.

Further, this system component makes it possible for e.g. triggers to
easily add modifiers, enabling the writing of Castle Blood Automatic,
RPG or Tower Defense maps without the need for mods or hacks.

The 'Modifier' name was preferred over 'Modification' as it is shorter
and more readable, along with the logic that 'modifiers' store
'modifications' and this stores modifiers. Renaming of other functions
and classes has been left for future work for now.

Internally, this uses a JS data structure. If performance issues arise
with it in the future, this data structure or the whole component could
be moved to C++.
The performance has been tested to be about as fast as the current
implementations (and specifically much faster for global auras with no
icons). Testing showed that sending value modification messages was by
far the slowest part.

Comments by: leper, Stan, elexis
Differential Revision: https://code.wildfiregames.com/D274
This was SVN commit r22767.
2019-08-24 07:37:07 +00:00
040624acff Replace copy-assigning GUI<T>::GetSetting from c2a71e41bf with the reference returning GetSetting from 3dfa23cd25.
Avoids one or two dozen unoptimizable string copies and two CPos copies,
mostly in SetupText.

The reference return allows to mark values as const where the previous
one prevented that.
This also reveals unused variables where the previous code hid them.

Thus use unused variable "buffer_zone" in the otherwise unused (since
b1422137e5, refs 0f807c643a) CCheckBox::SetupText() from b5f6d19332 and
use the unused variable "scrollbar" in CInput GUIM_MOUSE_PRESS_LEFT from
4113aa0a36.

Refs unintentionally copied DrawCall cache due to GetSetting copying in
c19f3608a5, fixed in 8f4f8e240f.

Differential Revision: https://code.wildfiregames.com/D2215
This was SVN commit r22765.
2019-08-23 14:43:10 +00:00
4d77bd6542 Fix unused glooxwrapper variable following 61261d14fc, refs #2305, #5294, #5550.
The class didn't leak the m_Wrapped gloox Jingle for this program since
it's not set to owned, and it's not set to owned because gloox deletes
it.
It would have leaked if some other app would have used glooxwrapper with
owned = true, if gloox has a situation for that.

Differential Revision: https://code.wildfiregames.com/D2090
This was SVN commit r22764.
2019-08-23 12:04:20 +00:00
e02afa279c Remove hardcoded C++ fallback font from 70d84beab2 and according TODO from 924b0bf1b4 that was fixed in 6af0d7cfd3 by having the default style specify the default font.
Use references instead of copies for obtaining the font in SetupText().

Differential Revision: https://code.wildfiregames.com/D2214
This was SVN commit r22761.
2019-08-23 03:28:04 +00:00
8609041ddf Fix missing actual boolean check in the commit removing the odd way to check for a boolean in 77b81d8761.
Reported By: Vladislav
Reviewed By: Vladislav
This was SVN commit r22758.
2019-08-23 00:42:00 +00:00
f4990cf967 Mark some GUI functions as const, including the boolean ones from d4d5187c9d.
Rename MouseOver to IsMouseOver.

Reported By: Vladislav
This was SVN commit r22757.
2019-08-22 23:51:10 +00:00
0e26503cc6 Introduce IGUIObject::PlaySound to unify 19 copies of the UI sound play following 9565c60a14, refs #948.
Stops copying the CStrW each time a sound is played by using the
reference GetSetting variant.

Differential Revision: https://code.wildfiregames.com/D2209
This was SVN commit r22756.
2019-08-22 22:34:12 +00:00
659bf68cc7 Cleanup Camera and CGameView, removes a not needed method and refactors classes.
Commented By: Stan
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D2195
This was SVN commit r22755.
2019-08-22 20:49:58 +00:00
d4d5187c9d Use variadic template for RecurseObject from c2a71e41bf and move it from GUIutil to IGUIObject.
Unifies the four copies of the function while making it more versatile.
Supersede the hardcoded GUIRR enum and CheckIfRestricted function with a
flexible member function pointer.
Replace the custom IGUIObject iterator with a casually iterable
GetChildren getter, so that it is more obvious what it iterates on.
Implement TODO from e21ebb37f5, i.e. RecurseObject not iterating over
the base object.

Differential Revision: https://code.wildfiregames.com/D2204
Tested on: gcc 9.1.0, clang 8.0.1, VS2015

This was SVN commit r22744.
2019-08-21 13:22:25 +00:00
e1014aad3b Use CGUI& instead of CGUI* so that the 50+ users stop wondering whether or not that is null and can't even be mistaken to add redundant null checks preemptively.
Remove the remaining of such checks after d3e56f0f57 removed 21 of them
already.
2c47fbd66a initialized the pointer at construction time rather than at
random conditional events later.

Differential Revision: https://code.wildfiregames.com/D2205
Comments By: Vladislav, wraitii
Tested on: gcc 9.1.0, clang 8.0.1

This was SVN commit r22741.
2019-08-21 10:12:33 +00:00
486691b49a Moves and cleanups includes and public/private section of PostprocManager.
Reviewed By: elexis
This was SVN commit r22738.
2019-08-20 21:15:15 +00:00
e82d0867b2 Erase unused variable following 77b81d8761, clean two stray includes from c19f3608a5.
Confess a wrong word in a comment in c9c82d9daf and a typo in a comment
in 9985fcf5bd.

Differential Revision: https://code.wildfiregames.com/D2203
This was SVN commit r22720.
2019-08-20 10:51:29 +00:00
8b6eee672b Move GUI string parsing specializations to a separate file and remove __ParseString proxy.
Differential Revision: https://code.wildfiregames.com/D2194
This was SVN commit r22696.
2019-08-19 19:43:13 +00:00
77b81d8761 Remove IsBoolTrue helper function from c399dc277e.
This property is defined as a boolean for every IGUIObject.
If GUIObjects were empowered to make up their own hidden property, then
they should also be empowered to use custom boolean hidden properties
that don't trigger ResetStates.

This was SVN commit r22695.
2019-08-19 18:36:35 +00:00
d403d750f0 Stop copying color every draw call for every GUI object using colors.
Avoid color copies for rendering Draw calls in
GUIRenderer::UpdateDrawCallCache, CButton::Draw, CChart::DrawAxes,
CDropDown::Draw, CList::DrawList, COList::DrawList, refs #1984,
8f4f8e240f, 3028551b91, a905fbbc98.
Avoid color copies during XML loading in CGUI::Xeromyces_ReadImage,
CGUI::Xeromyces_ReadEffects, COList::HandleAdditionalChildren.
Add CGUI::HasPreDefinedColor and mark m_PreDefinedColors,
CGUI::GetPreDefinedColor, IGUIButtonBehavior::ChooseColor() as const for
consistency with the other "databases", refs 3028551b91.
Mark CGUIColor as NONCOPYABLE to add compiler errors if there is an
unexplicit copy, refs 3028551b91.
Explicit ugly copy in CGUI::Xeromyces_ReadColor and
CGUIColor::ParseString.
Deregister copying <CGUIColor>GetSetting functions, refs 8f4f8e240f.
Uses the const ref GetSetting from 3dfa23cd25.

This was SVN commit r22694.
2019-08-19 12:53:58 +00:00
3dfa23cd25 Use a new GetSetting returning a reference instead of GetSettingPointer when the setting is known to exist.
Differential Revision: https://code.wildfiregames.com/D2192
This was SVN commit r22693.
2019-08-19 10:32:29 +00:00
5cfef19a06 Simplify the translations maintenance script.
- Removed bashisms
- Removed the call to SVN update which is usually done beforehand in CI
- Removed the git alternative which is never used
- Fixed the call to poediff which seems to fail with latest poediff

Tested on Jenkins since the revamp.
Reviewed By: Gallaecio
Differential Revision: https://code.wildfiregames.com/D2078
This was SVN commit r22690.
2019-08-18 18:13:04 +00:00
9985fcf5bd Move GUI<>::FallBackSprite and GUI<>::FallBackColor to CGUIColor::operator|| and CGUISpriteInstance::operator||.
Leaves only setting management in GUIutil.h.

Differential Revision: https://code.wildfiregames.com/D2185
This was SVN commit r22689.
2019-08-18 15:17:49 +00:00
c9c82d9daf Use shared_ptr to avoid copying and deleting SGUIImageEffects, 2.5x faster in a benchmark, refs ba0ebd6644.
Differential Revision: https://code.wildfiregames.com/D2184
Refs 3028551b91/D2163
Tested on: gcc 9, Jenkins

This was SVN commit r22682.
2019-08-17 11:52:57 +00:00
742f361b2d Improve performance of ScriptInterface::CreateObject from b4626359f5 / D2080 by creating the JSAutoRequest struct only once instead of once per property.
Differential Revision: https://code.wildfiregames.com/D2127
Comments By: Vladislav
This was SVN commit r22680.
2019-08-17 03:30:07 +00:00
ba56191dc2 Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.

Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline

This was SVN commit r22679.
2019-08-17 01:32:11 +00:00
24f97d9fd5 Fix unreported glooxwrapper leaks following 61261d14fc, refs #2305.
Fixes an occurring leak indicated by the reported clang unused variable
compiler warning, refs #5294, #5550,
by adding the missing glooxwrapper::Jingle::Session::Session destructor
.

Fix two leaks that would have occurred if the according code had been
used:
Delete unused glooxwrapper::Jingle::ICEUDP::ICEUDP instead of adding the
missing destructor.
Delete unused glooxwrapper::Jingle::Content::Content instead of adding
the missing destructor.

Explain why glooxwrapper::Client::registerStanzaExtension doesn't leak
the new StanzaExtensionWrapper.
Explain why glooxwrapper::Jingle::Session::sessionInitiate doesn't leak
the new gloox::Jingle::Content, nor the new gloox::Jingle::ICEUDP.
Explain why glooxwrapper::SessionManager::registerPlugins doesn't leak
the new gloox::Jingle::Content and new gloox::Jingle::ICEUDP.
Explain why glooxwrapper::SessionManager::createSession doesn't leak the
gloox::Jingle::Session.

I will not leak memory in the glooxwrapper.
I will not leak memory in the glooxwrapper.
I will not leak memory in the glooxwrapper.

Use references in the StunClient and glooxwrapper to anticipate any
confusion as to whose obligation it is to delete variables when they are
passed around across several files.
Use static_cast and reinterpret_cast instead of C-style casts in the
StunClient.

Differential Revision: https://code.wildfiregames.com/D2094
Refs D2093 for the reported leaks.
Reviewed By: Josh
Comments By: fcxSanya, Vladislav for D2094, and echotangoecho, leper in
61261d14fc

This was SVN commit r22678.
2019-08-17 00:12:19 +00:00
86c151ebaa PushGuiPage support for passing a function instead of a function name.
Allows coding the GUI without global functions which break
prototype-oriented coding, refs #5322, fixing the concern in 4b1297b328.

Supports stacked message boxes and removes the according workaround.
Change structree / civinfo switch-dialog code from 760a47335d to perform
the callback for page that actually registered the callback.
Ensure the parent that the callbackhandler is always called if the page
is closed.
Merge PopGuiPage and PopGuiPageCB following that choice, incidentally
leaving cleaner code.

Differential Revision: https://code.wildfiregames.com/D1684
Comments by: Yves, Vladislav, wraitii, leper
This was SVN commit r22676.
2019-08-16 18:46:04 +00:00
a06cfe309b Fix miniupnp memory leak from 667537ee49 again after it was fixed in 5876ec38d1 and probably accidentally reverted in 0ba25e9968, refs #2305.
Differential Revision: https://code.wildfiregames.com/D2183
Comments by: wraitii
Tested on: gcc 9, valgrind

This was SVN commit r22675.
2019-08-16 18:07:23 +00:00
8a4d2a8ccc Fix e83f24e3a6 and 1ff20e8f6a miniupnpc leak and crash on thread exit.
std::thread crashes when destroyed without being joined or detached.
Joining would wait on the UPnP thread, which can take upwards of 10
seconds, so detach instead.

Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2181
This was SVN commit r22674.
2019-08-16 17:38:58 +00:00
43df94c246 Fix 2a485c5e3b Wind computation - switch to signed integers.
Silences a GCC 9 warning and the logic was faulty.

Reported by: elexis
Differential Revision: https://code.wildfiregames.com/D2180
This was SVN commit r22670.
2019-08-15 17:02:53 +00:00
2a485c5e3b Wind speed computation rework.
This reworks wind-speed computation to not use a blurred-heightmap
approach but rather a slightly more wind simulation approach. It fixes
issues near the edges of some maps.

Differential Revision: https://code.wildfiregames.com/D1721
This was SVN commit r22668.
2019-08-15 11:56:00 +00:00
1ff20e8f6a pthread -> std::thread (4/7) - Replace pthread in remaining files
This removes pthread mutexes/threads from:
- vfs
- the resource handler manager
- timer
- the network server.

This allows removing it from our general posix include header.

Differential Revision: https://code.wildfiregames.com/D1920
This was SVN commit r22666.
2019-08-15 09:07:16 +00:00
6ad90aa1b8 Delete wrongful proxy CGUIManager::GetPreDefinedColor from f0d9806b3f.
It is wrong because the predefined colors should be loaded from the GUI
page that requests to have the color parsed, which may be different from
the topmost page.
Similar to FindObjectByName removed in f9b529f2fb.

Achieve this by implementing the CGUISetting<CGUIColor>::FromJSVal
specialization, moved from ScriptInterface::FromJSVal<CGUIColor>,
instead of adding a CGUI pointer to CGUIColor.
Mark ScriptInterface::FromJSVal<GUIColor> and inherited
CColor::ParseString explicitly as deleted, so that people get a compile
error if they forget to check for predefined colors when parsing a
color.

Refs #5387, D1746 > D1684 > this > f9b529f2fb, 9be8a560a9, 415939b59b,
2c47fbd66a, 85a622b13a.

Differential Revision: https://code.wildfiregames.com/D2108
Tested on: clang 8, VS2015

This was SVN commit r22663.
2019-08-13 18:00:41 +00:00
02d23d1ff0 Remove useless proxy GUI<int>::ParseColor, refs 31f0e62c83, 2c14d94559.
Tested on: clang 8.

This was SVN commit r22662.
2019-08-13 15:42:14 +00:00
64e80471d0 Replace JS_THIS_OBJECT and JS::CallReceiver in preparation for SpiderMonkey 49 and 61.
Differential Revision: https://code.wildfiregames.com/D2173
Refs #4893, D1699, D2142, D844, 7c2e9027c2, ...
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1270977
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1255800
Tested on: clang 8, VS2015, Jenkins

This was SVN commit r22661.
2019-08-13 14:11:43 +00:00
a908ce889c Hierarchical Pathfinder - Add Global Regions / Optimise MakeGoalReachable
Optimise MakeGoalReachable using global regions, by leveraging the fact
that we can easily know which goal regions we can reach. Particularly
for point-goals, it becomes almost instant.
This does not change hashes.

Differential Revision: https://code.wildfiregames.com/D1835
This was SVN commit r22653.
2019-08-12 13:19:01 +00:00
07dfacdc67 Fix build without precompiled headers in 107d3d461f.
Also remove an un-needed variable.

Patch by: elexis
This was SVN commit r22652.
2019-08-12 12:56:32 +00:00
107d3d461f pthread -> std::thread (3/7) - Replace pthread in other engine files
MapGenerator, TextureConverter, and some other files used pthread.

Differential Revision: https://code.wildfiregames.com/D1917
This was SVN commit r22649.
2019-08-12 08:16:28 +00:00
8ef8a9de89 Fix VisualActor OOS introduced in rp22586
A call to SelectAnimation("idle") was left over.

Reported by: elexis
Fixes #5552

Differential Revision: https://code.wildfiregames.com/D2169
This was SVN commit r22648.
2019-08-12 08:05:04 +00:00
801d5cbe68 Fix checkrefs script following eab4f9fdde (phenotypes), and fix the unit_motion_integration_test map from b637fdbae9.
In eab4f9fdde the `gender`-tag was replaced with `phenotype`. the
checkrefs script however was not updated and complained.

b637fdbae9 introduced a map that checkrefs did not validate.

Based on a patch by: Freagarach
Differential Revision: https://code.wildfiregames.com/D2141
This was SVN commit r22647.
2019-08-12 08:03:23 +00:00
838889ab12 Split CGUIString.h from GUIText.h, so that one may have the SGUIText implementation in a separate cpp file.
Differential Revision: https://code.wildfiregames.com/D2167
Reviewed By: Vladislav
Tested on: gcc 9.0.1, VS2015, Jenkins

This was SVN commit r22643.
2019-08-10 19:16:52 +00:00
d3e56f0f57 Unfriend the 20 IGUIObject classes from CGUI.
Improves separation of concerns and makes the code less error prone,
since the IGUIObject classes can't break CGUI private members without
CGUIs help anymore.

This is achieved by making CGUI GetFocusedObject, UpdateObjects public,
by introducing public CGUI GetBaseObject, GetMousePos, GetMouseButtons,
HasStyle, GetStyle getters,
and by removing the pointless IGUIObject GetMousePos proxy.

Delete GetGUI() checks that are either always or never true following
2c47fbd66a.
Use const references instead of copies for some mouse positions.

Differential Revision: https://code.wildfiregames.com/D2166
This was SVN commit r22641.
2019-08-10 12:51:27 +00:00
a905fbbc98 Use NONCOPYABLE for most GUI classes and structs to have the compiler indicate unintended copies, refs 3028551b91 / D2163.
That is CChartData, CGUIList, CGUISeries, COListColumn, GUITooltip,
SGUIMessage, SSpriteCall, STextCall, SFeedback, IGUISetting,
CGUISetting, GUI, IGUIObject, IGUIScrollBar.
Drop copying GetSetting and SetSetting template functions for CGUIList,
CGUISeries, CClientArea, CGUIString.
Stop copying COListColumn.
Drop copying GUI<CClientArea>::GetSetting call in
IGUIObject::UpdateCachedSize() and four copying
GUI<CGUIString>::GetSetting calls in SetupText() functions.
Delete unused GUIRenderer IGLState class from 849f50a500 obsolete since
1f5b8f1c9a.

Differential Revision: https://code.wildfiregames.com/D2164
This was SVN commit r22638.
2019-08-10 00:04:17 +00:00
3028551b91 MOVABLE idiom, const CGUI struct maps, in place move construction instead of copying temporaries during CGUI XML loading and GenerateText.
Introduce MOVABLE idiom indicating that a class can use move semantics.
Make values of CGUI struct maps holding XML data const to ensure at the
root that the data is not modified.
Use NONCOPYABLE and MOVABLE for SGUIIcon and SGUIStyle to enforce the
non-copy policy on the compiler level (until someone changes the GUI
design to make modifications needed).

As indicated by that:
  Replace copy operations by in place move operations for these CGUI
struct maps in the CGUI Xeromyces XML loading functions.
  Replace copy operations by const references for CSize and SGUIIcon in
CGUIString::GenerateTextCall and CGUI::GenerateText.
  This avoids copying of non primitive members, such as the strings and
containers of strings.

Further related cleanup to be kept separated for auditability.

Differential Revision: https://code.wildfiregames.com/D2163
Few comments on IRC by: wraitii, Itms
Tested on: gcc 9, Jenkins, partially VS2015

Refs #1984,
  NONCOPYABLE CGUISpriteInstances: 0a7d0ecdde, 8f4f8e240f, c19f3608a5
  NONCOPYABLE Image, Sprite: fb8032043b
  NONCOPYABLE GUI page: 94c57085e9
  NONCOPYABLE GUIManager: 7c2e9027c2
  NONCOPYABLE macro: 16ccae10cd

This was SVN commit r22637.
2019-08-09 17:25:55 +00:00
f804226b89 Fix failure of the CGUIColor constructor author to call the base constructor following f236c07a56, refs 415939b59b.
Tested on: gcc 9, VS2015

This was SVN commit r22636.
2019-08-09 14:54:14 +00:00
9325992232 Revert use of the isRunOnce flag after removal in 64b477625d of compile'n go, refs #4893.
This breaked a SM assertion, which was only caught in debug mode. It
could have led to subtle bugs during the compilation of JS scripts.
Still set the flag to its default value, because SM devs wanted to
change the default in the future.

This was SVN commit r22629.
2019-08-08 09:05:42 +00:00
64b477625d Upgrade SpiderMonkey to version 45.0.2, refs #4893.
- Various build changes, in particular NSPR is not needed on Unix
anymore
- Add js/Initialization.h to source/scriptinterface/ScriptEngine.h
- Use nullptr instead of JS::NullPtr(), see
https://bugzilla.mozilla.org/show_bug.cgi?id=1164602
- Remove `JS::RuntimeOptionsRef.varObjFix`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1171177
- Remove uses of `AutoIdArray`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1191529
- `JS_InternUCStringN` has been renamed, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1178581
- `JS::Evaluate` now takes scope chains explicitly, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1097987
- Array functions (such as `JS_IsArrayObject`) are fallible and output
to params, see https://bugzilla.mozilla.org/show_bug.cgi?id=f3d35d8
- Remove `JSCLASS_CACHED_PROTO_WIDTH` workaround in our code, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1236373
- Remove compile'n go (`setCompileAndGo`) and replace it by
`setIsRunOnce` which will become the default in the future, see
https://bugzilla.mozilla.org/show_bug.cgi?id=679939
- Mark shared memory in direct access operations
(`JS_GetUint16ArrayData` and `JS_GetUint8ArrayData`), see
https://bugzilla.mozilla.org/show_bug.cgi?id=1176214
- Use new `JS::ObjectOpResult`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1113369

Thanks to wraitii, elexis, Krinkle and historic_bruno for contributions
and comments, and to gentz, madpilot, s0600204 and Stan for testing and
indirect contributions.

Differential Revision: https://code.wildfiregames.com/D1510
This was SVN commit r22627.
2019-08-07 22:37:43 +00:00
7876ca7acb Fix gcc 8 compiler warning in FileIo.cpp about truncating use of strncpy [-Wstringop-truncation].
Refs #5294
Differential Revision: https://code.wildfiregames.com/D2159
Tested on: gcc 9, Jenkins

This was SVN commit r22626.
2019-08-07 15:38:40 +00:00
82f765b4cc Add Profiler2 static const member definition, since the declaration itself is insufficient for const ref access, as revealed in debug builds but not release builds following f89f90d56e and 9965f43067.
Differential Revision: https://code.wildfiregames.com/D2158
This was SVN commit r22625.
2019-08-07 14:45:13 +00:00
f89f90d56e Fix Profiler2 gcc 8 compiler warning about possible out-of-bounds array access and replace auto with their type, refs #5294, 3cbe96d24c.
Tested with gcc 9, clang 8

This was SVN commit r22624.
2019-08-07 09:12:28 +00:00
eb20fe3626 Replace ScriptInterface ErrorReporter layered hack from 5e15a0279e with proper code, refs f6c1d98c9a.
Avoids preparation for the SpiderMonkey 45 update, refs #4893 / D1510 .
Add JSAutoRequest missing from 5e15a0279e too.

Differential Revision: https://code.wildfiregames.com/D2152
Reviewed By: Itms
This was SVN commit r22622.
2019-08-06 22:13:06 +00:00
d35f16e4f5 Remove unused texture test helper function obsolete since dee3cb84b5 and ef888367aa that throws a compiler warning with gcc 7 and beyond.
Refs #2456, #5294.
Differential Revision: https://code.wildfiregames.com/D2153
This was SVN commit r22621.
2019-08-06 21:00:36 +00:00
df40b88c71 Fix ModIo.cpp gcc 7 compiler warning about extended alignment by using a pointer for hash_state as expected by sodium anyhow, following 833c9f108c, refs #5294.
Differential Revision: https://code.wildfiregames.com/D2102
Reviewed By: Itms
Comments By: historic_bruno
This was SVN commit r22619.
2019-08-06 13:06:15 +00:00
f236c07a56 Call CGUIColor base constructor without C++17 using declaration following 415939b59b.
This removes the trigger for an unidentified VS2015 bug revealed by the
IGUIObject::AddSetting / CGUISetting constructor in 85a622b13a
(unset GUIObject color settings didn't hold the color assigned in the
inherited default constructor, so hovered button text appeared black
instead of white on Windows).
The code in the two commits seems correct, but VS2015 doesn't seem to
implement it correctly (and claims to support C++17) while clang and gcc
behave as intended.
Fix whitespace.

Reported By: gameboy, Angen
Refs
https://wildfiregames.com/forum/index.php?/topic/26694-strange-font-color/

This was SVN commit r22617.
2019-08-05 20:45:15 +00:00
bb
7e1f959db0 redo 2d57478781, Create a ConfigDB_CreateAndWriteValueToFile function to absorb some duplication in the gui
Move two duplicated lines from 7e14a33411 in a function

fixes 2d57478781
Reviewed By: elexis
Comments By: Stan, vladislav
Differential Revision: https://code.wildfiregames.com/D1939
This was SVN commit r22615.
2019-08-05 14:12:55 +00:00
69abe717e3 Fix no-pch build following renderer options refactoring 5c4d124d2a
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2148
This was SVN commit r22612.
2019-08-04 20:08:06 +00:00
5c4d124d2a Refactor renderer options.
This moves the renderer options into their own class to:@
  - allow one to only include the rendering options, not the whole
renderer header, when one wants access to rendering options.
  - centralise rendering changes and their side-effects.
  - clean up code.

Tested by: historic_bruno, Freagarach
Commented by: historic_bruno
Differential Revision: https://code.wildfiregames.com/D1929
This was SVN commit r22610.
2019-08-04 08:28:30 +00:00
2ff8614ce2 Unit Motion - Improve behaviour around obstructions and unreachable goals
Use the "pretend correct path" behaviour for short goals too. This is a
fix for #5545, since the position check now works correctly without
needing to add a tricky check for path-vs-path distance.

Simplify HandleObstructedMove to use ComputePathToGoal more. This means
we occasionally compute a long path when stuck, which fixes two cases of
stuck units reported in #5547.

Move some common calls into functions for convenience.

Make sure the short-path-waypoint-range-relaxing introduced in
32e8ed51aa doesn't happen for the last waypoint, which caused units to
occasionally never get in range of the last waypoint.

Clear short path waypoints when computing a long path.

This won't fix all instances of unit dancing, but it should improve most
of them.

Fixes #5545, Fixes #5547

Differential Revision: https://code.wildfiregames.com/D2135
This was SVN commit r22609.
2019-08-04 08:16:09 +00:00
9ece3e7088 Pthread -> std::thread (2/7) - Remove pthread in Profilers
Use std::thread and thread_local instead of pthread specific calls.

Differential Revision: https://code.wildfiregames.com/D1916
This was SVN commit r22608.
2019-08-04 08:11:58 +00:00
c4789fdcc7 Fix missing ShadowMap headers in previous, da4e601d8f.
Tested on: gcc, clang

This was SVN commit r22606.
2019-08-04 05:58:55 +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
85a622b13a Implement IGUIObject settings as a template class and IGUIObject::AddSetting as a template function.
This means the type information is available for all methods operating
with the setting type, which is easier for the authors, allows for
compile-time checks and optimizations.
Remove the enum that was used to indirectly obtain the setting type at
runtime.
Revises SGUISetting and enum from e326ebae46 (5122b0f906),
std::function from 82f1d2718b.

Differential Revision: https://code.wildfiregames.com/D2145
Tested on: gcc, clang, VS2015, Jenkins

This was SVN commit r22604.
2019-08-04 02:20:08 +00:00
5a1da77ce4 Use IGUIObject::GetSettingPointer and SetSetting instead of accessing the member m_pSetting directly following fd91563f42.
Revise 53b335f5ae in CInput::UpdateBufferPositionSetting to use the
SkipMessage argument from 4113aa0a36 to prevent the infinite loop
instead of hijacking the pointer.

This was SVN commit r22603.
2019-08-04 00:02:56 +00:00
cd82b62e25 Fix JSInterface_IGUITextOwner build on VS2015 following 3d07327837 (which works on gcc, clang and Jenkins), reported by minohaka.
Retract IGUIObject override keyword from that commit, because clang
recommends to use it for either every or no overriding class member
(which then should be done consistently for all classes inheriting
IGUIObject, refs D2144).

This was SVN commit r22602.
2019-08-03 17:52:56 +00:00
3d07327837 Introduce a JSInterface_IGUITextOwner to encapsulate JSI_IGUIObject::getTextSize from 9c5062147a / D844.
JSI_IGUIObject should not contain functions that work only for some GUI
Object types, refs #5442.

Deduplicate the shuffled copy of CText::SetupText.

Avoid the 80 times slower dynamic_cast mandated by the virtual class
inheritance by adding an ugly overridable pointer to the base class
pointing at this derived classes, as bargained with Vladislav and
proposed by wraitii in D1781 id=8426.
This may be improved by refactoring the IGUIObject and JSInterface
classes to use templates and / or eliminating its virtual inheritance.

Implement and use FromJSVal / ToJSVal CSize specialization.
Remove the JS::CallArgsFromVp call.

Differential Revision: https://code.wildfiregames.com/D2136
Comments By: wraitii, Vladislav
This was SVN commit r22596.
2019-08-02 16:55:15 +00:00
df489f2500 Add virtual CreateJSObject to IGUIObject, split from GetJSObject, so that inheriting classes can extend the JS object upon construction, refs #5442, D2136.
Remove the comment from 53bcba3368 that allures the reader to believe
there is a memory leak which is not and has not been the case, refs
D1700.
Remove the useless JSAutoRequest from GetJSObject if the object was
constructed already (performance improvement), following cx assignment
in 4b1297b328, following JSAutoRequest addition in e9e05f4efc (that also
had removed other useles JSAutoRequest calls but not this one).
Don't change JS::PersistentRooted to JS::Heap until SpiderMonkey is
updated, refs D1700.
Provide access to GUI, ScriptHandlers and JSObject for inheriting
classes.

This was SVN commit r22593.
2019-08-02 12:18:30 +00:00
52f2bfae2b Add virtual base initialization missing in 2c47fbd66a.
Reported by Jenkins, but not gcc, clang, VS2015.
Take the opportunity following 2c47fbd66a to make the CGUI pointer held
by IGUIObject constant (the address, not the value).

Differential Revision: https://code.wildfiregames.com/D2139
This was SVN commit r22589.
2019-08-01 23:55:10 +00:00
69ac0b9656 Move CGUIManager::LoadPage to CGUIManager::SGUIPage::LoadPage, because it only operates only on that struct.
Refs D1684 (patch also made an appearance in D2108)

This was SVN commit r22588.
2019-08-01 20:48:05 +00:00
2c47fbd66a Pass the GUI page pointer CGUI* to the IGUIObject and derived classes upon construction, instead of on stray cases.
Call JS_AddExtraGCRootsTracer and JS_RemoveExtraGCRootsTracer depending
on JS::Heap use instead of on CGUI page link setup.
GUIObjects should be able to access the GUI page independent of the
scripting (for example to obtain PredefinedColors, refs D2108).

Refs: D2108, c02a7e1a7b
Comments By: wraitii
This was SVN commit r22587.
2019-08-01 20:20:24 +00:00
eab4f9fdde Replace {gender} by {phenotype} and support this tag in VisualActor.
A random phenotype can be chosen by giving multiple tokens to the
template.
This allows giving different looks to the same template.

Comments By: stan, vladislav, elexis
Patch By: Freagarach
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1955
This was SVN commit r22586.
2019-08-01 19:14:40 +00:00
82f1d2718b Remove both copies of the 15-fold copies of the JSI_IGUIObject::getProperty and setProperty setting case handlers following the FromJSVal / ToJSVal template specializations implemented in
* JSI_GUIColor in 9be8a560a9
* bool in eec179a9a8
* CGUISeries and CGUIList in 26ae9d430a
* primitives in 636c719110
* EAlign and EVAlign in 0834d07462
* ClientArea in b9f3c8557b
* CColor in 415939b59b
* CGUISpriteInstance 0a7d0ecdde
* CPos in d6b93b3be6

The removed JS_ReportError calls were redundant.

This was SVN commit r22574.
2019-07-29 14:46:29 +00:00
d6b93b3be6 Add missing CPos FromJSVal, ToJSVal following 659a9ea57a.
This was SVN commit r22573.
2019-07-29 11:56:11 +00:00
0a7d0ecdde CGUISpriteInstance non-copyable and FromJSVal / ToJSVal.
Make CGUISpriteInstance non-copyable to further harden Philips
protection from 8f4f8e240f against unintentional copies of its DrawCall
cache such as in c19f3608a5.
Remove its copy constructor from 849f50a500, make it movable, and until
it becomes otherwise necessary, force move assignment when sprites are
assigned.
Improves the fixes of the compiler warnings about deprecated implicit
copy constructors in 8a32b0b3d4 by avoiding the copies instead of
copying explicitly.
Add ToJSVal, FromJSVal for CGUISprinteInstance to make
JSI_IGUIObject::getProperty and setProperty more consistent.
Rename Sprite operator= to SetName to reduce ambiguity.
Pass CRect by reference in CGUISpriteInstance::Draw.

Differential Revision: https://code.wildfiregames.com/D2133
Comments By: wraitii
This was SVN commit r22570.
2019-07-28 22:40:58 +00:00
c03abd1e92 UnitMotion cleanup - remove dead code, add a common path for MoveTo functions, rename BeginPathing, move functions around for better readability.
BeginPathing renamed to ComputePathToGoal, as that is what this function
does.
IsMoving renamed to IsMoveRequested, as the function returns true when
the unit has a move request going on, not when it is actually moving
across the map, which was misleading.

UpdateMovementState's implementation moved closer to where it is used.

PathIsShort and WAYPOINT_ADVANCE_MAX are currently unused, thus deleted.

Differential Revision: https://code.wildfiregames.com/D2067
This was SVN commit r22568.
2019-07-28 10:51:12 +00:00
1e2f511a09 UnitMotion - reject paths that would not take the unit closer to the goal than it is now.
This helps with #3144 and units not going idle when ordered to clump
together.

By rejecting paths that would not take the unit closer to the goal than
it is, we can avoid the case where a unit at A finds a short path to B,
goes there, gets stuck, finds a new short path to A, etc. ad infinitum.

It doesn't completely fix the problem since two units moving might still
occasionally become stuck against one another, but it makes it rarer
(unit pushing would probably finish solving this).

This assumes that being as close as possible to the goal is the best
behaviour when trying to move somewhere, even when it is unreachable.

Refs #3144

Differential Revision: https://code.wildfiregames.com/D2075
This was SVN commit r22566.
2019-07-28 10:29:28 +00:00
ad4de3d3be Delete CInternalCGUIAccessorBase class from c2a71e41bf.
Delete GetSetting/SetSetting variants that operate on a GUI page other
than the one that the setting is defined in; introduced in c2a71e41bf,
obsolete since f0d9806b3f.

Delete CInternalCGUIAccessorBase::GetObjectPointer as these variants
were the only caller for that.
Delete CInternalCGUIAccessorBase::HandleMessage from a08cbd2f74 as it's
an unnecessary proxy.
Delete CInternalCGUIAccessorBase::QueryResetting from 953f72a91c by
making ResetStates public, equal to UpdateCachedSize from 90bbd48a14
(public required for VS2015 but not gcc 9).
Move ResetStates to implementation file.

Tested on: gcc 9, VS2015

This was SVN commit r22563.
2019-07-28 02:39:52 +00:00
6b052bab08 Fix 415939b59b - clang-specific error at compilation time
JS_ReportError was passed a CStr, which it doesn't support.

Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2131
This was SVN commit r22561.
2019-07-27 15:12:59 +00:00
b7d1ea671f Update Errors definition file following:
I18n Script SetupFailed removal in 818ea52c3b,
Renderer VBOFailed removal in 2f28b07356,
CVFSFile InvalidBufferAccess removal in b253cbbee6.

Differential Revision: https://code.wildfiregames.com/D2124
This was SVN commit r22559.
2019-07-26 19:27:10 +00:00
415939b59b Introduce CGUIColor type inheriting Color type and switch the GUI to exclusively use that.
The type differs from the Color type, because contrary to Color, it can
be created from a color predefined in the GUI page (such as "yellow").
Move this predefined color check to the new class instead of hardcoding
it in FromJSVal / ToJSVal, GUIUtil, JSInterface_IGUIObject and to
straighten the latter.

Delete fov_wedge_color from Minimap, unused since introduction in
5275dc862b.

This was SVN commit r22558.
2019-07-26 18:57:28 +00:00
b9f3c8557b Move CClientArea ToJSVal / FromJSVal conversion from JSI_IGUIObject (since that should be agnostic of the conversion) to CClientArea (since that defines the properties).
This was SVN commit r22557.
2019-07-26 14:47:27 +00:00
0834d07462 Make JS changed horizontal / vertical actually take effect, finishing 156ff7cf56, refs f4b410ff82.
Move EAlign and EVAlign JS<->C++ conversions to FromJSVal and ToJSVal
for consistency.

Remove alternative / british spelling "centre".
Use i32 instead of int since at least and at most 32 bits are intended
there, refs 1e07787e76.

This was SVN commit r22556.
2019-07-26 13:45:14 +00:00
52d58d9845 Wipe MaybeGC/ForceGC declaration leftover from 9f0484e5ce / D1073.
This was SVN commit r22555.
2019-07-26 12:41:22 +00:00
8d293db6eb Removes clipboard debug logging on X11, fixes #5535
This was SVN commit r22551.
2019-07-25 05:34:04 +00:00
1e9cc3d43e Fixes missing Engine.DisplayErrorDialog in hwdetect.js (lost in 4b1297b328).
Fixes #5533.
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2123
This was SVN commit r22549.
2019-07-25 05:21:25 +00:00
4ced2182b2 Fixes compiler warning about unused variable introduced in 09e129bce2.
This was SVN commit r22548.
2019-07-24 23:25:45 +00:00
50f70b7be3 Refactors Camera aspect ratio and calculation of plane points.
Reviewed By: elexis
Commented By: wraitii
Differential Revision: https://code.wildfiregames.com/D2020
This was SVN commit r22547.
2019-07-24 23:08:02 +00:00
2cc071f306 Fix memory leak introduced by 3a839517ce in SparseGrid
Following 3a839517ce, SparseGrid::Reset() replaces the value of m_Data
(a C-style dynamically sized array) with a new value-initialised array,
by using the new operator. Previous code simply did a memset.
This means that when m_Data was not null, it leaked memory as the
previous array was not deleted.

SparseGrid::Reset is called when destroying the sparse grid, and a
SparseGrid is used by the long pathfinder when computing JPS paths. As
that is called rather often, it resulted in a relatively serious memory
leak that could make very long games use several GB of memory.

This fixes the leak by using placement new, which re-uses the memory,
effectively doing the same as the previously existing memset.

Profiling by historic_bruno and elexis showed that performance from
value-initialising with placement new was at worst similar to memset,
and testing shows this was compiled in a memset call in several cases
anyways.

Reviewed By: elexis
Fixes #5522

Differential Revision: https://code.wildfiregames.com/D2121
This was SVN commit r22545.
2019-07-24 17:11:22 +00:00
ae7e43ff19 Alt+tab fix for ca9109be75 - call sound IdleTask in Atlas and swap buffers only once in Atlas.
- ca9109be75 moved SwapBuffers inside Render - this makes Atlas call it
twice in a row which might behave oddly (did not seem to though) and
anyways was wasteful.
- ca9109be75 moved IdleTask from the sound manager outside of Render.
This means atlas never called IdleTask, and this broke sounds after a
few seconds.

Reviewed By: Angen
Differential Revision: https://code.wildfiregames.com/D2029
This was SVN commit r22544.
2019-07-24 16:40:34 +00:00
636c719110 Use FromJSVal ToJSVal for primitive types to remove the duplicate logic and make JSInterface_IGUIObject case handling more equal.
Remove broken uint overflow check from 3698c134b5 and just use the
native JS uint32 conversion.

This was SVN commit r22540.
2019-07-24 02:58:50 +00:00
26ae9d430a CGUISeries and CGUIList specializations for ToJSVal / FromJSVal to make the JSI_IGUIObject case handling agnostic of implementation specifics, refs 4d367109c3, 977a5c7ca2, 2bae30c454.
This was SVN commit r22539.
2019-07-24 01:40:30 +00:00
eec179a9a8 Use FromJSVal and ToJSVal for GUI boolean conversions.
Consistently warn instead of using implicit conversion when not passing
a boolean, for consistency and callers being more cautious with passed
values.

This was SVN commit r22538.
2019-07-23 21:46:32 +00:00
62f83eb673 Use ToJSVal for JS_NewStringCopyZ to improve encapsulation and consistency and remove a snprintf call.
This was SVN commit r22536.
2019-07-23 15:17:35 +00:00
cbcd1bbde0 There is nothing to see here following 9be8a560a9.
This was SVN commit r22535.
2019-07-23 14:50:09 +00:00
9be8a560a9 Delete JSClass JSI_GUIColor / GUIColor from af9c336b43, refs #5387, D1699.
* JSI_GUIColor::construct and JSI_IGUIObject::setProperty hunk are
duplicates of FromJSVal, getProperty of ToJSVal, following 7c2e9027c2.
* The constructor, it's fallback magenta and toString have never been
used by JS.
* A JS color class providing some methods (such as found in color.js,
refs #5387, and the unused toString redundant with rgbToGuiColor, see
also eee8217b45) is more inviting to changes and maintenance if defined
in JS and can still be instantiated in C++, like the Vector2D (see also
65b02395b3).
* PredefinedColors (such as "red" or "green") can be obtained from the
prototype without defining the class in C++.
* Minimize ugliness by removing macrosity, refs 8ceb41212d.

Rename alpha to a in guiToRgbColor from eee8217b45 for consistency with
the C++ conversions (opaqueness had been skipped in the only callers of
this JS function yet).
Delete unused GUISTDTYPE Mouse in header forgotton in 8734efca94.

This was SVN commit r22534.
2019-07-23 14:22:27 +00:00
7a823ca671 UnitMotion - Fix a rare pathfinding issues where units tried going straight through walls, and make sure a long path is computed even when the target is within short path or direct path range.
This fixes a regression introduced by 055c848c1a: when an entity is
ordered to move to a target within short path distance (or direct path
distance), it no longer computed at least one long path, which meant it
could be stuck forever if the target was not actually reachable (such as
behind a wall).
To fix this, compute a long path after 3 failed computations, which
should result in a delay of 1-3 turns. The previous code did this after
1 failed try - the decision to make it 3 is mostly based on the idea
that in most cases, being stuck means we ran into units, not that we
were ordered somewhere close. Should there be complaints, it could be
lowered to 2 or 1.

This fixes a second issue, reported in #4473: units sometimes get stuck,
particularly when trying to garrison a turret from 'inside' the walls.
The issue is that the turret is not accessible via the inside as its
obstruction + garrison range is blocked by the surrounding walls.
However, as introduced by 6e05a00929, TryGoingStraightToTargetEntity
ignores all entities with the obstruction group of the target (the
reason for this being that otherwise it would never succeed, since the
line towards the target would likely go through the target).
For walls and formations, this means ignoring possibly too many
entities, and in the case of #4473, ignoring wall pieces. The unit thus
mistakenly thought it could direct-path to the turret, and got stuck.

To fix this, we can ignore specifically the targeted entity's
obstruction tag. This can be considered a fix to 6e05a00929.

temple accepted an earlier version of this patch (specifically elexis'
version).

Fixes #4473

Based on a patch by: elexis
Differential Revision: https://code.wildfiregames.com/D1424
This was SVN commit r22533.
2019-07-23 06:18:07 +00:00
8734efca94 Delete JSI_GUIMouse from af9c336b43 obsoleted by 64bd264fc0.
Excerpt of D1699.

This was SVN commit r22531.
2019-07-23 01:36:13 +00:00
227957cd99 Delete unused broken JSI_IGUIObject::construct.
The constructor is invalid, because one cannot create or obtain and pass
an IGUIObject C++ class instance pointer via JS, only triggering a crash
when doing something with it.
If there was a use case, the GUIObject should be created with a
GUIObject type specific constructor.
Remove obsolete getProperty comments.

From D1699, refs #5369 and wraitiis equivalent:
Differential Revision: https://code.wildfiregames.com/D1933
This was SVN commit r22530.
2019-07-23 01:24:49 +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
32e8ed51aa UnitMotion - Send messages to UnitAI when obstructed, to allow stopping early when walking and avoiding pathfinding lag.
As reported by #5521, Ordering units to walk to a point in a forest can
lag terribly, as units will end up computing long short paths in the
forest, which can result in `ComputeShortPath` calls that individually
take upwards of 80ms.

This can be alleviated by allowing units to stop a bit earlier. A23
handled this in UnitMotion directly, but it's better to handle this in
UnitAI to avoid surprises and to make it customisable on a per-state
level.

This diff further speeds up using the short pathfinder by starting with
a smaller search range, limiting the max-range more and moving the range
slightly towards the goal.

This also refactors UM sending messages to UnitAI so that we may in the
future push more information (in particular, the entity_id that a unit
was obstructed by could be interesting for COMBAT).

This doesn't fix the possibility of lag, but it reduces its occurrence
to levels that should be similar to A23 and thus acceptable enough.

Tested By: Freagarach
Fixes #5521

Differential Revision: https://code.wildfiregames.com/D2105
This was SVN commit r22526.
2019-07-22 18:07:24 +00:00
51419d7092 Correct uncaught MapReader and MapGenerator throw statements following 2b138f47db and 2180862d40.
Differential Revision: https://code.wildfiregames.com/D2089
Reviewed By: historic_bruno
This was SVN commit r22521.
2019-07-21 01:35:39 +00:00
41ee485e68 Remove unused GUIManager SGUIPage members from 7c2e9027c2 and 4b1297b328.
This was SVN commit r22520.
2019-07-21 01:29:08 +00:00
13209c3183 Revert 09916ce6cb which broken jenkins build.
This was SVN commit r22519.
2019-07-20 13:10:53 +00:00