Opened 3 years ago
Closed 16 months ago
#6302 closed defect (fixed)
Warning in Atlas about GetTechModifiedProperty
Reported by: | Langbart | Owned by: | Freagarach |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 27 |
Component: | Atlas editor | Keywords: | |
Cc: | Patch: | Phab:D4881 |
Description (last modified by )
Starting an AI simulation in Atlas throws the following warnings:
WARNING: GetTechModifiedProperty: numeric modification format not recognised : ({affects:["Unit", "Structure"], multiply:(void 0)}) WARNING: GetTechModifiedProperty: numeric modification format not recognised : ({affects:["Unit", "Structure"], multiply:(void 0)})
The problem can be reproduced consistently for the current SVN [25877] version, for A25, for A24b, but the warnings do not occur in A23b.
Steps:
- Open Atlas
- Click on
Change Players
- Select AI for player 1
- Click on
Generate map
Stan wrote under patch D3784
Pretty sure it started with the modifiers manager in A24.
The warnings do not appear at [21945] (A23b macOS), I managed to compile up to [24278] and the warnings still appear.
The ModifiersManager.js was added with [22767], but I am not able to compile with this changeset number, I get problems with the library files on macOS.
Attachments (1)
Change History (10)
by , 3 years ago
Attachment: | GetTechModifiedProperty.jpg added |
---|
comment:1 by , 3 years ago
Description: | modified (diff) |
---|
comment:2 by , 2 years ago
Milestone: | Alpha 26 → Alpha 27 |
---|
comment:3 by , 16 months ago
Patch: | → Phab:D4881 |
---|
comment:4 by , 16 months ago
comment:5 by , 16 months ago
I was investigating this ticket and I found there reason about this error:
Im going to add the trace
GetTechModifiedProperty_numeric@globalscripts/Technologies.js:68:14 GetTechModifiedProperty@globalscripts/Technologies.js:27:10 ModifiersManager.prototype.FetchModifiedProperty@simulation/components/ModifiersManager.js:110:9 ModifiersManager.prototype.ApplyTemplateModifiers@simulation/components/ModifiersManager.js:193:14 ApplyValueModificationsToTemplate@simulation/helpers/ValueModification.js:19:31 AIInterface.prototype.OnTemplateModification@simulation/components/AIInterface.js:256:52 ModifiersManager.prototype.SendPlayerModifierMessages@simulation/components/ModifiersManager.js:69:9 ModifiersManager.prototype.ModifiersChanged@simulation/components/ModifiersManager.js:60:9 ModifiersManager.prototype.Init/this.modifiersStorage._OnItemModified@simulation/components/ModifiersManager.js:23:87 MultiKeyMap.prototype.AddItem@globalscripts/MultiKeyMap.js:49:7 MultiKeyMap.prototype.AddItems@globalscripts/MultiKeyMap.js:62:19 ModifiersManager.prototype.AddModifiers@simulation/components/ModifiersManager.js:265:31 InitGame@simulation/helpers/InitGame.js:64:24
When you generate a random map it call "InitGame" and in L58
let AIDiff = +settings.PlayerData[i].AIDiff;
AIDiff is undifined but that "+" make AIDiff to "NaN", so Math.min is going to return "NaN" but rate[AIDiff] is going to return "undefined".
cmpAIManager.AddPlayer(settings.PlayerData[i].AI, i, AIDiff, settings.PlayerData[i].AIBehavior || "random"); cmpPlayer.SetAI(true); AIDiff = Math.min(AIDiff, rate.length - 1); cmpModifiersManager.AddModifiers("AI Bonus", { "ResourceGatherer/BaseSpeed": [{ "affects": ["Unit", "Structure"], "multiply": rate[AIDiff] }], "Trader/GainMultiplier": [{ "affects": ["Unit", "Structure"], "multiply": rate[AIDiff] }], "Cost/BuildTime": [{ "affects": ["Unit", "Structure"], "multiply": time[AIDiff] }], }, cmpPlayer.entity);
the code above have a dependency for this variable.
Now why this is happen, well the current code from AtlasUI (widget) the only attribute set is AI nothing else you can see here https://code.wildfiregames.com/source/0ad/browse/ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp$882
so we can have three options to resolve the problem:
- (easy one) Add the validation about AIDiff early in the if code
if (settings.PlayerData[i] && !!settings.PlayerData[i].AI && !!settings.PlayerData[i].AIDiff)
- (another easy) set the default value if inst defined (like AIBehavior) with 3
let AIDiff = +settings.PlayerData[i].AIDiff || 3;
- (hard one) expand AtlasUI to handle AIBehavior and AIDiff
What should be use? suggestions?
follow-up: 8 comment:6 by , 16 months ago
my third option is add this lines in https://code.wildfiregames.com/source/0ad/browse/ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp$882
player.set("AI", str->GetData().utf8_str()); player.setInt("AIDiff", (*playerDefs["AIDiff"]).getInt()); player.set("AIBehavior", (*playerDefs["AIBehavior"]));
comment:7 by , 16 months ago
I'm not sure which option is the best yet. Depending on how long AtlasUI as we know it will stay
How are other defaults handled? In JS or in CPP?
comment:8 by , 16 months ago
Replying to trompetin17:
- (easy one) Add the validation about AIDiff early in the if code
if (settings.PlayerData[i] && !!settings.PlayerData[i].AI && !!settings.PlayerData[i].AIDiff)
In this solution, the entities would not be controlled by the AI in Atlas, but would just stand there.
- (another easy) set the default value if inst defined (like AIBehavior) with 3
let AIDiff = +settings.PlayerData[i].AIDiff || 3;
this would work, but I don't like the 3
- Don't Repeat Yourself (DRY)
Line | |
---|---|
418 | assignplayers = everyone ; Whether to assign joining clients to free playerslots. Possible values: everyone, buddies, disabled. |
419 | aidifficulty = 3 ; Difficulty level, from 0 (easiest) to 5 (hardest) |
420 | aibehavior = "random" ; Default behavior of the AI (random, balanced, aggressive or defensive) |
Replying to trompetin17:
my fourth option is add this lines in Sections/Player/Player.cpp
-
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp
a b AtObj PlayerSettingsControl::UpdateSettingsObject() 880 880 // ai - get id 881 881 wxStringClientData* str = dynamic_cast<wxStringClientData*>(choice->GetClientObject(choice->GetSelection())); 882 882 player.set("AI", str->GetData().utf8_str()); 883 player.setInt("AIDiff", (*playerDefs["AIDiff"]).getInt()); 884 player.set("AIBehavior", (*playerDefs["AIBehavior"])); 883 885 } 884 886 else // human 885 887 player.unset("AI");
this would work or Phab:D488, flip a coin, commit, close ticket.
You can let the IRC WildfireBot
decide for you
# Randomly chooses <num> items out of the arguments given. # https://github.com/progval/Limnoria/tree/master/plugins/Utilities @sample 1 " trompetin17" "Freagarach"
(Not assigning myself since this patch probably just hides the problem.)