Page MenuHomeWildfire Games

Add safeguards for all queryOwnerInterface calls
ClosedPublic

Authored by bb on Aug 26 2020, 1:21 PM.

Details

Summary

While reviewing D2810, I noticed that many of the Interfaces queried with queryOwnerInterface don't have safeguards for nonexistance. Usually not a problem since they exists, however they need to be checked.

Test Plan

grep and see all have safeguards now
Agree with the proposed safeguards
Observe effectively nothing changes

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
SeverityLocationCodeMessage
Errorbinaries/data/mods/public/simulation/helpers/Commands.js:43ESLintBear (no-use-before-define)ESLintBear (no-use-before-define)
Errorbinaries/data/mods/public/simulation/helpers/Commands.js:47ESLintBear (no-use-before-define)ESLintBear (no-use-before-define)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:53JSHintBearJSHintBear
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:531ESLintBear (operator-linebreak)ESLintBear (operator-linebreak)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:531JSHintBearJSHintBear
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:532ESLintBear (indent)ESLintBear (indent)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:726JSHintBearJSHintBear
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:788ESLintBear (no-shadow)ESLintBear (no-shadow)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1145ESLintBear (key-spacing)ESLintBear (key-spacing)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1145ESLintBear (key-spacing)ESLintBear (key-spacing)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1145ESLintBear (space-in-parens)ESLintBear (space-in-parens)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1253ESLintBear (spaced-comment)ESLintBear (spaced-comment)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1273ESLintBear (no-mixed-spaces-and-tabs)ESLintBear (no-mixed-spaces-and-tabs)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1274ESLintBear (no-mixed-spaces-and-tabs)ESLintBear (no-mixed-spaces-and-tabs)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1317ESLintBear (spaced-comment)ESLintBear (spaced-comment)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1481ESLintBear (operator-linebreak)ESLintBear (operator-linebreak)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1504ESLintBear (no-undef-init)ESLintBear (no-undef-init)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1583ESLintBear (no-undef-init)ESLintBear (no-undef-init)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1588ESLintBear (comma-spacing)ESLintBear (comma-spacing)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1612ESLintBear (comma-spacing)ESLintBear (comma-spacing)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1613ESLintBear (comma-spacing)ESLintBear (comma-spacing)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1614ESLintBear (comma-spacing)ESLintBear (comma-spacing)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1615ESLintBear (comma-spacing)ESLintBear (comma-spacing)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1619ESLintBear (comma-spacing)ESLintBear (comma-spacing)
Warningbinaries/data/mods/public/simulation/helpers/Commands.js:1621ESLintBear (comma-spacing)ESLintBear (comma-spacing)
Unit
No Unit Test Coverage
Build Status
Buildable 13024
Build 25719: Vulcan BuildJenkins
Build 25718: Vulcan Build (macOS)Jenkins
Build 25717: Vulcan Build (Windows)Jenkins
Build 25716: arc lint + arc unit

Event Timeline

bb created this revision.Aug 26 2020, 1:21 PM
Owners added a subscriber: Restricted Owners Package.Aug 26 2020, 1:21 PM
bb requested review of this revision.Aug 26 2020, 1:29 PM

Seems good overall

binaries/data/mods/public/simulation/components/ProductionQueue.js
451

I feel like this should be a straight warning/error. Seems buggy, particularly since you've already subtracted resources.

827

Likewise -> makes no sense to have a tech template if the owner has no technology manager

893

samesies

Freagarach added inline comments.
binaries/data/mods/public/simulation/components/Promotion.js
88

Can't we use the template value when we have no player?

binaries/data/mods/public/simulation/helpers/Commands.js
302

Perhaps update the warnings as well?

Silier added a subscriber: Silier.Aug 27 2020, 2:14 PM
Silier added inline comments.
binaries/data/mods/public/simulation/components/Promotion.js
88

no player means owner is invalid so entity is mostly dead

bb updated this revision to Diff 13330.Aug 28 2020, 6:59 PM
bb marked 2 inline comments as done.
bb added inline comments.
binaries/data/mods/public/simulation/components/ProductionQueue.js
451

A second look showed, we already check for cmpTechnologyManager in this.GetTechnologiesList, so strictly we don't need to check this. Don't really like querying the interface twice, but out of scope

binaries/data/mods/public/simulation/components/Promotion.js
88

Afaik the template doesn't contain a player ID

binaries/data/mods/public/simulation/helpers/Commands.js
302

not much to change here, since no cmpPlayerEntityLimits means no limits, hence we just pass by

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

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

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

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

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

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

Freagarach added inline comments.Aug 28 2020, 7:03 PM
binaries/data/mods/public/simulation/components/Promotion.js
88

I meant using +template.Promotion.RequiredXp. But Angen may be right and it may not be needed.

bb updated this revision to Diff 13331.Aug 28 2020, 7:56 PM
Freagarach added a comment.EditedSep 18 2020, 2:48 PM

This is complete and correct (awaiting the answer).

binaries/data/mods/public/simulation/components/ProductionQueue.js
383

Should one still be allowed to train a restricted entity when there is no IID_EntityLimits? To me that equals having a limit of 0 so we should return here.

Freagarach accepted this revision.Sep 18 2020, 3:02 PM
This revision is now accepted and ready to land.Sep 18 2020, 3:02 PM
This revision was automatically updated to reflect the committed changes.