Ticket #3236: Cost_js_fix_population_cost_and bonus.patch
File Cost_js_fix_population_cost_and bonus.patch, 3.3 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Cost.js
97 97 var popDifference = newPopBonus - this.populationBonus; 98 98 if (!popDifference) 99 99 return; 100 this.populationBonus = newPopBonus; 100 101 101 102 var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); 102 103 if (cmpPlayer) -
binaries/data/mods/public/simulation/components/ProductionQueue.js
244 244 if (type == "unit") 245 245 { 246 246 // Find the template data so we can determine the build costs 247 var cmpTemp Man= Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);248 var template = cmpTemp Man.GetTemplate(templateName);247 var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); 248 var template = cmpTemplateManager.GetTemplate(templateName); 249 249 if (!template) 250 250 return; 251 251 if (template.Promotion) … … 275 275 totalCosts[r] = Math.floor(count * costs[r]); 276 276 } 277 277 278 var population = +template.Cost.Population;278 var population = ApplyValueModificationsToTemplate("Cost/Population", +template.Cost.Population, cmpPlayer.GetPlayerID(), template); 279 279 280 280 // TrySubtractResources should report error to player (they ran out of resources) 281 281 if (!cmpPlayer.TrySubtractResources(totalCosts)) … … 309 309 else if (type == "technology") 310 310 { 311 311 // Load the technology template 312 var cmpTech TempMan= Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);313 var template = cmpTech TempMan.GetTemplate(templateName);312 var cmpTechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager); 313 var template = cmpTechnologyTemplateManager.GetTemplate(templateName); 314 314 if (!template) 315 315 return; 316 316 var cmpPlayer = QueryOwnerInterface(this.entity); … … 395 395 // Update entity count in the EntityLimits component 396 396 if (item.unitTemplate) 397 397 { 398 var cmpTemp Man= Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);399 var template = cmpTemp Man.GetTemplate(item.unitTemplate);398 var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); 399 var template = cmpTemplateManager.GetTemplate(item.unitTemplate); 400 400 if (template.TrainingRestrictions) 401 401 { 402 402 var unitCategory = template.TrainingRestrictions.Category; … … 665 665 // If the item is a unit then do population checks 666 666 if (item.unitTemplate) 667 667 { 668 // If something change population cost 669 var template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate(item.unitTemplate); 670 item.population = ApplyValueModificationsToTemplate("Cost/Population", +template.Cost.Population, item.player, template); 671 668 672 // Batch's training hasn't started yet. 669 673 // Try to reserve the necessary population slots 670 674 item.neededSlots = cmpPlayer.TryReservePopulationSlots(item.population * item.count);