Opened 12 years ago

Closed 11 years ago

#1692 closed enhancement (fixed)

Small technology code cleanup

Reported by: Kieran P Owned by: Jonathan Waller
Priority: Should Have Milestone: Alpha 13
Component: UI & Simulation Keywords: simple
Cc: Patch:

Description (last modified by Jonathan Waller)

Extract the if (cmpTechMan) conditional and code into a global helper function.

Also, make the whole tech engine take arguments in this order: entity/player, tech type, current value

function ApplyTechModificationsToEntity(entity, tech_type, current_value) {
  var cmpTechMan = QueryOwnerInterface(entity, IID_TechnologyManager);

  if (!cmpTechMan)
    return current_value;

  return cmpTechMan.ApplyModifications(entity, tech_type, current_value); 
}

function ApplyTechModificationsToPlayer(player_entity, tech_type, current_value) {
  var cmpTechMan = Engine.QueryInterface(player_entity, IID_TechnologyManager);

  if (!cmpTechMan)
    return current_value;

  return cmpTechMan.ApplyModifications(player_entity, tech_type, current_value); 
}

ApplyTechModificationsToEntity(this.entity, "Health/Max", +this.template.Max);
ApplyTechModificationsToPlayer(this.entity, "Player/MaxPopulation", +this.template.MaxPopulation);

Change History (10)

comment:1 by Kieran P, 12 years ago

Component: Core engineUI & Simulation
Description: modified (diff)

comment:2 by Jonathan Waller, 12 years ago

Description: modified (diff)

comment:3 by Jonathan Waller, 12 years ago

Description: modified (diff)

comment:4 by Kieran P, 11 years ago

Milestone: Alpha 12Backlog

comment:5 by Jonathan Waller, 11 years ago

Keywords: simple added

comment:6 by Jonathan Waller, 11 years ago

In 13056:

Make technology code cleaner with helper functions. Refs #1692.

comment:7 by leper, 11 years ago

In 13059:

Add template helper function. Fix some errors. Refs #1692.

comment:8 by leper, 11 years ago

The player/entity ordering has a problem with templates (needed in ProductionQueue).

comment:9 by leper, 11 years ago

Milestone: BacklogAlpha 13

comment:10 by leper, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.