Page MenuHomeWildfire Games

Allow to change the interval in Resource trickle
ClosedPublic

Authored by Stan on Jun 6 2020, 7:20 PM.

Details

Reviewers
Freagarach
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP23879: Allow the interval to be changed in the templates for the Resource Trickle…
Trac Tickets
#5632
Summary

@Polakrity asked on D2400 if the timer interval could be made configurable for Trickle as well, this patch does that

Test Plan

Add a modifier for interval, check everything works correctly and that update is more or less frequent.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Stan created this revision.Jun 6 2020, 7:20 PM
Vulcan added a comment.Jun 6 2020, 7:21 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2349/display/redirect

Stan updated this revision to Diff 12187.Jun 6 2020, 7:25 PM
Stan added a subscriber: Freagarach.

Merge loop, fix oversight. @Freagarach, got a use case for your update function :)

Stan retitled this revision from Allow to change the interval in Resource trickly to Allow to change the interval in Resource trickle.Jun 6 2020, 7:25 PM
Vulcan added a comment.Jun 6 2020, 7:26 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2350/display/redirect

Vulcan added a comment.Jun 6 2020, 7:37 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1818/display/redirect

Vulcan added a comment.Jun 6 2020, 7:38 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1819/display/redirect

Freagarach added inline comments.Jun 7 2020, 10:17 AM
binaries/data/mods/public/simulation/components/ResourceTrickle.js
14 ↗(On Diff #12187)

This is not needed since it is computed in the check timer.

18 ↗(On Diff #12187)

The name of the function is not what it does ^^

79 ↗(On Diff #12187)

One could cache the old value and do this.trickeInterval = Apply,,, directly?

80 ↗(On Diff #12187)

Also check whether the interval is positive (and non-zero).

84 ↗(On Diff #12187)

Comment not needed?

87 ↗(On Diff #12187)

Move to the declaration.

Freagarach added inline comments.Jul 9 2020, 8:10 AM
binaries/data/mods/public/simulation/components/ResourceTrickle.js
85 ↗(On Diff #12187)

Early return?

Stan updated this revision to Diff 12610.Jul 9 2020, 8:57 AM
Stan marked 5 inline comments as done.

Inlines.

binaries/data/mods/public/simulation/components/ResourceTrickle.js
87 ↗(On Diff #12187)

No, else we compute it in some cases for nothing :)

Stan marked 2 inline comments as done.Jul 9 2020, 8:58 AM
Vulcan added a comment.Jul 9 2020, 8:58 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/2067/display/redirect

Vulcan added a comment.Jul 9 2020, 9:01 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2600/display/redirect

Vulcan added a comment.Jul 9 2020, 9:06 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/968/display/redirect

Stan updated this revision to Diff 12611.Jul 9 2020, 9:09 AM

Fix tests, add test

Vulcan added a comment.Jul 9 2020, 9:10 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/2068/display/redirect

Stan updated this revision to Diff 12612.Jul 9 2020, 9:11 AM

Forgot to register the global again

Vulcan added a comment.Jul 9 2020, 9:12 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2601/display/redirect

Vulcan added a comment.Jul 9 2020, 9:12 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/2069/display/redirect

Vulcan added a comment.Jul 9 2020, 9:13 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2602/display/redirect

Freagarach added inline comments.Jul 9 2020, 9:17 AM
binaries/data/mods/public/simulation/components/ResourceTrickle.js
79 ↗(On Diff #12187)

I guess one wants to store the trickleInterval even if it is zero?

87 ↗(On Diff #12187)

But now you declare it in vain for some cases ;)

binaries/data/mods/public/simulation/components/tests/test_ResourceTrickle.js
99 ↗(On Diff #12612)

Do you need the OnUpdate?

Vulcan added a comment.Jul 9 2020, 9:18 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/969/display/redirect

Vulcan added a comment.Jul 9 2020, 9:26 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/970/display/redirect

Stan updated this revision to Diff 12613.Jul 9 2020, 9:44 AM

Try again

Stan updated this revision to Diff 12615.Jul 9 2020, 9:46 AM

Don't set interval depending on resource

Vulcan added a comment.Jul 9 2020, 9:46 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/2070/display/redirect

Vulcan added a comment.Jul 9 2020, 9:46 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2603/display/redirect

Stan marked 3 inline comments as done.Jul 9 2020, 9:47 AM
Vulcan added a comment.Jul 9 2020, 9:48 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/2071/display/redirect

Vulcan added a comment.Jul 9 2020, 9:48 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2604/display/redirect

Stan updated this revision to Diff 12616.Jul 9 2020, 9:51 AM

Remove variable

Vulcan added a comment.Jul 9 2020, 9:52 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/2072/display/redirect

Vulcan added a comment.Jul 9 2020, 9:53 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2605/display/redirect

Vulcan added a comment.Jul 9 2020, 9:53 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/971/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/972/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/973/display/redirect

Stan updated this revision to Diff 12617.Jul 9 2020, 10:32 AM

More tests

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2606/display/redirect

Freagarach added inline comments.Jul 9 2020, 10:42 AM
binaries/data/mods/public/simulation/components/ResourceTrickle.js
68 ↗(On Diff #12617)

I still think this is strange ^^'

95 ↗(On Diff #12617)

This needs a space and perhaps a comment?

Stan updated this revision to Diff 12618.Jul 9 2020, 10:47 AM
Stan marked an inline comment as done.

Add comment inline cmpTimer, apparently JavaScript allows this, and EsLint does not complain

Stan marked an inline comment as done.Jul 9 2020, 10:47 AM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2607/display/redirect

Freagarach added inline comments.Jul 9 2020, 11:11 AM
binaries/data/mods/public/simulation/components/ResourceTrickle.js
79 ↗(On Diff #12618)

|| 0 not needed anymore (since you've set it on init now).

81 ↗(On Diff #12618)

What happens when the oldTrickeInterval was 0 and we try here to cancel the invalidated timer?

94 ↗(On Diff #12618)

invalidated before (or earlier) to note it did not become invalidated on this turn.

Stan updated this revision to Diff 12619.Jul 9 2020, 11:21 AM
Stan marked 3 inline comments as done.

Fix inlines

binaries/data/mods/public/simulation/components/ResourceTrickle.js
81 ↗(On Diff #12618)

[11:20:17] ‎Stan‎: Freagarach, when you cancel a cancelled timer delete returns false instead of true
‎[11:20:48] ‎Freagarach‎: So we're okay :)

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2608/display/redirect

Freagarach accepted this revision.Jul 9 2020, 11:50 AM
  • Tested in game, interval applied appropriately.
  • Code looks good.
  • Common use cases tested.
This revision is now accepted and ready to land.Jul 9 2020, 11:50 AM