mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 19:43:45 +00:00
Units should only be able to build structures from their owner's civ, and not from their identity civ
Reviewed By: elexis Trac Tickets: #4870 Differential Revision: https://code.wildfiregames.com/D1065 This was SVN commit r20521.
This commit is contained in:
@@ -810,9 +810,10 @@ m.GameState.prototype.findTrainers = function(template)
|
||||
*/
|
||||
m.GameState.prototype.findBuilder = function(template)
|
||||
{
|
||||
let civ = this.getPlayerCiv();
|
||||
for (let ent of this.getOwnUnits().values())
|
||||
{
|
||||
let buildable = ent.buildableEntities();
|
||||
let buildable = ent.buildableEntities(civ);
|
||||
if (buildable && buildable.indexOf(template) !== -1)
|
||||
return ent;
|
||||
}
|
||||
|
||||
@@ -38,10 +38,16 @@ m.ConstructionPlan.prototype.start = function(gameState)
|
||||
{
|
||||
Engine.ProfileStart("Building construction start");
|
||||
|
||||
// We don't care which builder we assign, since they won't actually
|
||||
// do the building themselves - all we care about is that there is
|
||||
// at least one unit that can start the foundation
|
||||
// We don't care which builder we assign, since they won't actually do
|
||||
// the building themselves - all we care about is that there is at least
|
||||
// one unit that can start the foundation (should always be the case here).
|
||||
let builder = gameState.findBuilder(this.type);
|
||||
if (!builder)
|
||||
{
|
||||
API3.warn("petra error: builder not found when starting construction.");
|
||||
Engine.ProfileStop();
|
||||
return;
|
||||
}
|
||||
|
||||
let pos = this.findGoodPosition(gameState);
|
||||
if (!pos)
|
||||
|
||||
@@ -27,19 +27,14 @@ Builder.prototype.Serialize = null; // we have no dynamic state to save
|
||||
Builder.prototype.GetEntitiesList = function()
|
||||
{
|
||||
let string = this.template.Entities._string;
|
||||
|
||||
if (!string)
|
||||
return [];
|
||||
|
||||
let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
|
||||
if (cmpIdentity)
|
||||
string = string.replace(/\{civ\}/g, cmpIdentity.GetCiv());
|
||||
|
||||
let entities = string.split(/\s+/);
|
||||
|
||||
let cmpPlayer = QueryOwnerInterface(this.entity);
|
||||
if (!cmpPlayer)
|
||||
return entities;
|
||||
return [];
|
||||
|
||||
let entities = string.replace(/\{civ\}/g, cmpPlayer.GetCiv()).split(/\s+/);
|
||||
|
||||
let disabledTemplates = cmpPlayer.GetDisabledTemplates();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user