Ticket #1374: errorReport.2.patch

File errorReport.2.patch, 2.6 KB (added by s0600204, 9 years ago)

Minor adjustments to previous version of patch

  • gui/common/functions_civinfo.js

     
    77
    88
    99function loadCivData()
    10 {   // Load all JSON files containing civ data
     10{
     11    // Load all JSON files containing civ data
    1112    var civData = {};
    1213    var civFiles = Engine.BuildDirEntList("civs/", "*.json", false);
    1314   
    1415    for each (var filename in civFiles)
    15     {   // Parse data if valid file
     16    {
     17        // Parse data if valid file
    1618        var data = parseJSONData(filename);
     19        if (Object.keys(data).length == 0)
     20            continue;
    1721        translateObjectKeys(data, ["Name", "Description", "History", "Special"]);
    1822        civData[data.Code] = data;
    1923    }
  • simulation/components/TechnologyTemplateManager.js

     
    1919{
    2020    if (!this.allTechs[template])
    2121    {
    22         this.allTechs[template] = Engine.ReadJSONFile("technologies/" + template + ".json");
    23         if (!this.allTechs[template])
    24             error("Failed to load technology \"" + template + "\"");
     22        try
     23        {
     24            this.allTechs[template] = Engine.ReadJSONFile("technologies/" + template + ".json");
     25        }
     26        catch (err)
     27        {
     28            error(sprintf("%(error)s in '%(path)s'", { error: err.toString(), path: template }));
     29        }
    2530    }
    2631
    27     return this.allTechs[template];
     32    return this.allTechs[template] || false;
    2833};
    2934
    3035TechnologyTemplateManager.prototype.GetAuraTemplate = function(template)
  • simulation/components/TechnologyManager.js

     
    283283
    284284    if (!template)
    285285    {
    286         error("Tried to research invalid techonology: " + uneval(tech));
     286        error("Tried to research invalid technology: " + uneval(tech));
    287287        return;
    288288    }
    289289
  • simulation/components/ProductionQueue.js

     
    241241            // Find the template data so we can determine the build costs
    242242            var cmpTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
    243243            var template = cmpTempMan.GetTemplate(templateName);
    244             if (!template)
     244            if (!template || Object.keys(template) == 0)
    245245                return;
    246246            if (template.Promotion)
    247247            {