Ticket #531 (closed task: fixed)

Opened 3 years ago

Last modified 13 months ago

Enforce Population Limit

Reported by: evans Owned by: evans
Priority: Should Have Milestone: Alpha 2
Component: UI & Simulation Keywords: review
Cc: philip

Description

Enforce Population Limit when training units. Units can be queued up for training past the population limit, but training will start only when there are enough population slots available.

Attachments

PopLimit.diff (6.5 KB) - added by evans 3 years ago.
PopulationBonus.patch (551 bytes) - added by fcxSanya 3 years ago.

Change History

Changed 3 years ago by evans

comment:1 Changed 3 years ago by Philip

Made some changes here:

  • Added a global QueryOwnerInterface function (instead of the GetPlayer), so we can get the player data from anywhere.
  • Changed the OwnershipChanged behaviour so it simply destroys the current queue on each change.
  • "" should always be followed by a space.
  • I think the !item.trainingStarted case would result in item.timeRemaining becoming negative and the unit not being trained immediately, if it started smaller than time (which is unlikely but possible), so I changed that.
  • Also tried to simplify some of the logic around updating the population reserve count.
  • Maybe some minor things I lost track of.

comment:2 Changed 3 years ago by philip

  • Status changed from new to closed
  • Resolution set to fixed

(In [8014]) # Population limits. Fix #531 (Enforce Population Limit), based on patch from evans. Empty training queue and refund resources when buildings are destroyed or captured. Specify Cost defaults in XML instead of JS, to simplify some code.

comment:3 Changed 3 years ago by evans

Shouldn't the default Pop Limit be 0 (instead of 50)?

Changed 3 years ago by fcxSanya

comment:4 Changed 3 years ago by fcxSanya

  • Status changed from closed to reopened
  • Resolution fixed deleted

In [8014] PopulationBonus element was made necessary from optional, but in source\simulation2\components\CCmpTemplateManager.cpp, CopyFoundationSubset function, there is lines:

if (out.GetChild("Entity").GetChild("Cost").IsOk())
    CParamNode::LoadXMLString(
        out, "<Entity><Cost><PopulationBonus disable=''/></Cost></Entity>"
    );

which disable this element for structures foundation.

So when I try to build a structure, I get error like this:

ERROR: CXeromyces: Parse error: foundation%7Cstructures/hele_barracks:1: 
    Expecting an element PopulationBonus, got nothing

ERROR: CXeromyces: Parse error: foundation%7Cstructures/hele_barracks:1: 
    Invalid sequence in interleave

ERROR: CXeromyces: Parse error: foundation%7Cstructures/hele_barracks:1: 
    Element Cost failed to validate content

ERROR: RelaxNGValidator: Validation failed

ERROR: JavaScript error: simulation/helpers/Commands.js line 84 TypeError: 
    cmpPosition is null

ERROR: Failed to call ProcessCommand() global script function

When I comment this lines:

if (out.GetChild("Entity").GetChild("Cost").IsOk())
    CParamNode::LoadXMLString(
        out, "<Entity><Cost><PopulationBonus disable=''/></Cost></Entity>"
    );

all works properly.

comment:5 Changed 3 years ago by Philip

evans: Yes, but I still find it a bit of a pain when testing (I guess we ought to have cheat codes that add pop/resources), and before #548 it'll probably confuse players who try to train units at the start of the game, so I don't really want to change it yet.

fcxSanya: Fixed in r8023.

comment:6 Changed 3 years ago by Philip

  • Status changed from reopened to closed
  • Resolution set to fixed

comment:7 Changed 3 years ago by anonymous

  • Milestone Unclassified deleted

Milestone Unclassified deleted

comment:8 Changed 13 months ago by historic_bruno

  • Milestone set to Alpha 2
Note: See TracTickets for help on using tickets.