mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
Warn when finding an entity with Reasearcher/Trainer but without ProductionQueue.
As requested by @Silier and @Stan.
Following 0c4f59d0a7.
Differential revision: https://code.wildfiregames.com/D4404
Comments by: @Silier, @smiley, @Stan
This was SVN commit r26200.
This commit is contained in:
parent
9757cc2539
commit
794fa82efb
3 changed files with 21 additions and 9 deletions
|
|
@ -627,13 +627,19 @@ g_SelectionPanels.Research = {
|
|||
{
|
||||
let ret = [];
|
||||
if (unitEntStates.length == 1)
|
||||
return !unitEntStates[0].researcher || !unitEntStates[0].researcher.technologies ? ret :
|
||||
unitEntStates[0].researcher.technologies.map(tech => ({
|
||||
"tech": tech,
|
||||
"techCostMultiplier": unitEntStates[0].researcher.techCostMultiplier,
|
||||
"researchFacilityId": unitEntStates[0].id,
|
||||
"isUpgrading": !!unitEntStates[0].upgrade && unitEntStates[0].upgrade.isUpgrading
|
||||
}));
|
||||
{
|
||||
const entState = unitEntStates[0];
|
||||
if (!entState?.researcher?.technologies)
|
||||
return ret;
|
||||
if (!entState.production)
|
||||
warn("Researcher without ProductionQueue found: " + entState.id + ".");
|
||||
return entState.researcher.technologies.map(tech => ({
|
||||
"tech": tech,
|
||||
"techCostMultiplier": entState.researcher.techCostMultiplier,
|
||||
"researchFacilityId": entState.id,
|
||||
"isUpgrading": !!entState.upgrade && entState.upgrade.isUpgrading
|
||||
}));
|
||||
}
|
||||
|
||||
let sortedEntStates = unitEntStates.sort((a, b) =>
|
||||
(!b.upgrade || !b.upgrade.isUpgrading) - (!a.upgrade || !a.upgrade.isUpgrading) ||
|
||||
|
|
@ -644,6 +650,8 @@ g_SelectionPanels.Research = {
|
|||
{
|
||||
if (!state.researcher || !state.researcher.technologies)
|
||||
continue;
|
||||
if (!state.production)
|
||||
warn("Researcher without ProductionQueue found: " + state.id + ".");
|
||||
|
||||
// Remove the techs we already have in ret (with the same name and techCostMultiplier)
|
||||
const filteredTechs = state.researcher.technologies.filter(
|
||||
|
|
|
|||
|
|
@ -1793,7 +1793,7 @@ var g_EntityCommands =
|
|||
"autoqueue-on": {
|
||||
"getInfo": function(entStates)
|
||||
{
|
||||
if (entStates.every(entState => !entState.trainer || !entState.trainer.entities.length || entState.production.autoqueue))
|
||||
if (entStates.every(entState => !entState.trainer?.entities?.length || !entState.production || entState.production.autoqueue))
|
||||
return false;
|
||||
return {
|
||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.queueunit.autoqueueon") +
|
||||
|
|
@ -1813,7 +1813,7 @@ var g_EntityCommands =
|
|||
"autoqueue-off": {
|
||||
"getInfo": function(entStates)
|
||||
{
|
||||
if (entStates.every(entState => !entState.trainer || !entState.trainer.entities.length || !entState.production.autoqueue))
|
||||
if (entStates.every(entState => !entState.production?.autoqueue))
|
||||
return false;
|
||||
return {
|
||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.queueunit.autoqueueoff") +
|
||||
|
|
|
|||
|
|
@ -192,7 +192,11 @@ function getAllTrainableEntities(selection)
|
|||
{
|
||||
let state = GetEntityState(ent);
|
||||
if (state?.trainer?.entities?.length)
|
||||
{
|
||||
if (!state.production)
|
||||
warn("Trainer without Production Queue found: " + ent + ".");
|
||||
trainableEnts = trainableEnts.concat(state.trainer.entities);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicates
|
||||
|
|
|
|||
Loading…
Reference in a new issue