Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#6724 closed defect (fixed)

Requirement tooltip errors for Ptolemaic barracks

Reported by: Langbart Owned by: Freagarach
Priority: Should Have Milestone: Alpha 27
Component: Core engine Keywords:
Cc: Patch:

Description

to reproduce

  • start map with ptol
  • build && select a Barrack
  • errors
  • the Royal Guard Infantry has two requirements phase_city and unlock_champion_infantry

errors

ERROR: JavaScript error: gui/common/l10n.js line 69
Script value conversion check failed: v.isString() || v.isNumber() || v.isBoolean() (got type undefined)
  translate@gui/common/l10n.js:69:36
  getRequirementsTooltip@gui/common/tooltips.js:975:23
  setupButton@gui/session/selection_panels.js:1051:4
  setupUnitPanel@gui/session/unit_commands.js:94:35
  updateUnitCommands@gui/session/unit_commands.js:152:18
  updateSelectionDetails@gui/session/selection_details.js:537:20
  updateGUIObjects@gui/session/session.js:730:2
  onSimulationUpdate@gui/session/session.js:680:2
  __eventhandler6 (SimulationUpdate)@session SimulationUpdate:1:1
ERROR: Errors executing script event "SimulationUpdate"

bisect

likley [27245]

possible solution

related ticket to requirement feature

#6705

Change History (7)

comment:1 by Freagarach, 15 months ago

[27505] I'll commit the proposed fix. ;P

Hmm maybe not.

comment:2 by Freagarach, 15 months ago

Owner: set to Freagarach
Resolution: fixed
Status: newclosed

In 27524:

Fix multiple requirements (and no tooltip) of the Ptol champion pikeman.

Reported by: @Langbart
Fixes #6724

comment:3 by Langbart, 15 months ago

okay, this works. other templates do it like this:

sele/champion_infantry_swordsman.xml

Line 
7 <SpecificName>Thorakitès Rhomaïkós</SpecificName>
8 <Icon>units/sele/champion_swordsman.png</Icon>
9 <Requirements>
10 <Techs datatype="tokens">-phase_city reformed_army_sele</Techs>
11 </Requirements>
12 </Identity>
13 <VisualActor>

I'm more concerned about how to spot this issue before it's released, I just happened to stumble across it, it severely affects gameplay, even partially prevents the production of new units in completely different buildings.

comment:4 by Freagarach, 15 months ago

Yeah, we can either remove the datatype (so it doesn't merge the tokens) or remove the earlier tech. The latter might be better.


It is indeed hard to spot, I've manually checked the templates before [27505], but playing reveals them more easily.

comment:5 by Langbart, 15 months ago

If you play latest delenda est it suffers from the same problem. Simply selecting the soldier disables the game.


warning ?

  • binaries/data/mods/public/gui/common/tooltips.js

    a b function getRequirementsTooltip(enabled, requirements, civ)  
    972972        return objectionFont(sprintf(translate("Requires %(technology)s"), {
    973973            "technology": getEntityNames(GetTechnologyData(requirements.Techs._string, civ))
    974974        }));
    975     return objectionFont(translate(requirements.Tooltip));
     975    if ("Tooltip" in requirements)
     976        return objectionFont(translate(requirements.Tooltip));
     977    return warn(`Multiple Tech requirements found - ${requirements.Techs._string.replace(/\s/,",")}, but no "<Tooltip>...</Tooltip>" specified`)
    976978}
    977979
    978980/**

EDIT:

  • at least check for undefined

    Always check for undefined properties and/or invalid object references, if it's possible they could occur.

Last edited 15 months ago by Langbart (previous) (diff)

comment:6 by Freagarach, 15 months ago

In 27530:

Properly use tokens for all Tech requirements.

Better than faking the fix with a flaw in the inheritance.
Refs. r27524 / rP27524 and r27505 / rP27505.

Differential revision: https://code.wildfiregames.com/D4924
Comments by: @Stan
Refs. #6724

comment:7 by Freagarach, 15 months ago

In 27531:

Don't error out on complex requirements without tooltip.

Since it is not nice to make the game unusable (citation needed) we'll emit a warning, which is less not nice.
Reported by: @Langbart

Differential revision: https://code.wildfiregames.com/D4930
Reviewed by: @Langbart
Fixes #6724

Note: See TracTickets for help on using tickets.