Ticket #2706: returncost.diff

File returncost.diff, 1.3 KB (added by fatherbushido, 6 years ago)

retrun cost when capturing or deleting

  • binaries/data/mods/public/simulation/components/Upgrade.js

    Upgrade.prototype.Init = function()  
    7474
    7575// On owner change, abort the upgrade
    7676// This will also deal with the "OnDestroy" case.
    7777Upgrade.prototype.OnOwnershipChanged = function(msg)
    7878{
    79     this.CancelUpgrade();
    80 
     79    this.CancelUpgrade(msg.from);
    8180    if (msg.to !== -1)
    8281        this.owner = msg.to;
    8382};
    8483
    8584Upgrade.prototype.ChangeUpgradedEntityCount = function(amount)
    Upgrade.prototype.Upgrade = function(tem  
    240239        this.UpgradeProgress();
    241240
    242241    return true;
    243242};
    244243
    245 Upgrade.prototype.CancelUpgrade = function()
     244Upgrade.prototype.CancelUpgrade = function(owner)
    246245{
    247246    if (!this.IsUpgrading())
    248247        return;
    249248
    250     let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player);
     249    let cmpPlayer = QueryPlayerIDInterface(owner, IID_Player);
    251250    if (cmpPlayer)
    252     {
    253         let costs = this.GetResourceCosts(this.upgrading);
    254         cmpPlayer.AddResources(costs);
    255     }
     251        cmpPlayer.AddResources(this.GetResourceCosts(this.upgrading));
    256252
    257253    this.ChangeUpgradedEntityCount(-1);
    258254
    259255    this.upgrading = false;
    260256    this.CancelTimer();