1
1
forked from 0ad/0ad
Commit Graph

19658 Commits

Author SHA1 Message Date
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
9fcfdb0324 Improve Attack's GetBestAttackAgainst by only considering attack types that actually can attack the target.
Patch By: freagarach
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D2112
This was SVN commit r22569.
2019-07-28 14:58:24 +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
d9c6879450 Fix units ignoring range when attacking in one case, and fix targeting formations
Fixes for 5568bd4c16:
- units could occasionally ignore range checks when attacking.
- attacking a formation wouldn't pick new targets correctly.

While testing, I also think the walk then walk and fight behaviour
should be changed to just walk and fight or units might just run towards
enemies and not attack them, which looks rather odd.

Reported By: Angen
Fixes #5530

Differential Revision: https://code.wildfiregames.com/D2119
This was SVN commit r22567.
2019-07-28 10:39:27 +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
103d89f026 GatherNearPositiion when the target remains invisible on our second try, instead of going idle.
This improves hunting behaviour, as targets may still be in FOW on the
second try, and the unit would go idle - instead it'll now gather near
position, which is more likely to find a proper resource.

Differential Revision: https://code.wildfiregames.com/D2071
This was SVN commit r22565.
2019-07-28 09:48:23 +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
3e4d339b51 Add a missing undefined to booelan conversion for the diplomacy dialog in eec179a9a8, fixes #5542.
Remove diplomacyMenuButton unused since introduction in a21e01150a.

This was SVN commit r22562.
2019-07-27 21:18:16 +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
wackyserious
b9544a2eaa New Ptolemy IV (Hero) Texture
Thread:
​https://wildfiregames.com/forum/index.php?/topic/26591-task-ptolemy-iv-rework/

Reviewed by: Stan, Nescio and wowgetoffyourcellphone
This was SVN commit r22554.
2019-07-26 11:10:43 +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
3532dd64ac Fix patrol order and make the relaxed range check into a constant.
Introduced by 32e8ed51aa.

Reported By: elexis
Fixes #5531 .

Differential Revision: https://code.wildfiregames.com/D2118
This was SVN commit r22546.
2019-07-24 19:05:12 +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
a783f430d5 Update the gather LastPos alongside the combat LastPos when hunting to more efficiently hunt.
When units are hunting, they push an attacking order in front.

That attacking order keeps track of the target's last known position to
efficiently hunt. However, if the unit goes out of LOS,
ShouldAbandonChase triggers and the unit goes back to the gather order -
which hby then as a hopelessly out of date "LastPos".
By updating the LastPos of the gather order as well, Gather can recover
efficiently.

Differential Revision: https://code.wildfiregames.com/D2072
This was SVN commit r22543.
2019-07-24 15:55:07 +00:00
wackyserious
7c2985bbe1 New Roman Units Texture
Thread:
https://wildfiregames.com/forum/index.php?/topic/25533-task-roman-infantry-new-texture/

Reviewed by: Art Department and (Sundiata, Genava55,
wowgetoffyourcellphone and Lion.Kanzen)

This was SVN commit r22542.
2019-07-24 06:53:04 +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
b04a8d4793 Disable eslint curly rule, because none of its configurable enforcement reflects the curly brace convention of this repository, refs #5524.
Differential Revision: https://code.wildfiregames.com/D2070
Patch By: Krinkle
Reviewed By: Imarok
This was SVN commit r22529.
2019-07-22 19:55:52 +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
6643613b54 Easier introduction of new damage types.
725aa8a686 introduced a DamageTypes.js global script similar to the
resources one. However, we never actually need to refer to this script
since we can always use the damage types provided by the
template/context/object we are looping over/...
There is one exception to this for AI weighting of damage types.
However, since damage types are not stored in files, this is strictly
equivalent to hardcoding them in the global script and was deemed
acceptable.

Patch By: freagarach
Reviewed By: wraitii
Refs #4801 (by invalidating it for now, though such helper files might
be useful in the future if damage types require more metadata).

Differential Revision: https://code.wildfiregames.com/D1938
This was SVN commit r22527.
2019-07-22 18:37:18 +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
Alexandermb
09315fdc6b Update Britons blacksmith_armorstand_armor.xml to use new @wackyserious chainmail textures
This was SVN commit r22524.
2019-07-22 00:55:23 +00:00
1a3ba39900 Trader linting, refs D2106.
Differential Revision: https://code.wildfiregames.com/D2107
Patch By: Angen
Comments By: Vulcan
This was SVN commit r22523.
2019-07-21 20:19:39 +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
09916ce6cb Fix incorrect use of setlocale() in cppformat CStr tests following 61db02790c
Reported By: elexis
Differential Revision: https://code.wildfiregames.com/D2013
This was SVN commit r22518.
2019-07-20 12:57:03 +00:00
cca7627d88 Improvements to simulation hotloading before the SM upgrade, refs #4893.
SM45 will enforce property attributes described at
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/Property_attributes.
We thus cannot hotload properties with the DontDelete attribute.
Fix an oversight in the hotloading code.
Rename a confusing parameter.

Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1844
This was SVN commit r22516.
2019-07-19 21:58:58 +00:00
feb88a337a Pass arbitrary arguments to GUI events / SendEventToAll and remove loading screen progess workaround, refs D1716, 6d792365aa, bd3bd084c0, 4b1297b328, db5d4bb5f1.
Differential Revision: https://code.wildfiregames.com/D1754
Reviewed By: Itms
Comments By: leper
This was SVN commit r22515.
2019-07-19 21:15:04 +00:00
498d58e24d Fix reported memory leaks in the glooxwrapper following 61261d14fc
Differential Revision: https://code.wildfiregames.com/D2093
Reviewed By: elexis
This was SVN commit r22514.
2019-07-19 19:46:48 +00:00
6230bbea24 Update of the scripting tests. Test some modding features and update JS::Value integer limits.
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1850
This was SVN commit r22513.
2019-07-19 15:41:27 +00:00
Alexandermb
6d332c0822 Fix for unsync siege weapons unpacked with horses idle animations
This was SVN commit r22512.
2019-07-19 15:30:49 +00:00
3a839517ce Fix the -Wclass-memaccess compiler warning in the pathfinders Grid.h, refs #5294.
Differential Revision: https://code.wildfiregames.com/D2099
Reviewed By: historic_bruno, wraitii
This was SVN commit r22511.
2019-07-19 12:52:10 +00:00
e6f960bca6 Makes wxWidgets 3.0 dependency explicit in the game build.
Removes a few non-behavioral workarounds for older versions.

Refs #5502, #2891.
Accepted By: asterix
Comments by: vladislavbelov
Differential Revision: https://code.wildfiregames.com/D2076
This was SVN commit r22508.
2019-07-19 04:52:03 +00:00