From dd895c95e3e4d985645b01ffc876a7d88080e077 Mon Sep 17 00:00:00 2001 From: Matei Date: Mon, 17 Jul 2006 02:38:43 +0000 Subject: [PATCH] Fixed a bug with resource updates, and made script profiling code be commented out by default in case it interferes with people (it shouldn't have taken too much time, but who knows). This was SVN commit r4128. --- .../official/gui/test/functions_sim_player.js | 6 +++++ .../mods/official/scripts/entity_functions.js | 23 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/binaries/data/mods/official/gui/test/functions_sim_player.js b/binaries/data/mods/official/gui/test/functions_sim_player.js index 9515ff5e56..3c14b44080 100644 --- a/binaries/data/mods/official/gui/test/functions_sim_player.js +++ b/binaries/data/mods/official/gui/test/functions_sim_player.js @@ -14,6 +14,12 @@ function createResourceCounters() addResourceCounter(2, "stone"); addResourceCounter(3, "ore"); addResourceCounter(4, "population"); + + refreshResource("Food", 0); + refreshResource("Wood", 1); + refreshResource("Stone", 2); + refreshResource("Ore", 3); + refreshResource("Population", 4); } // ==================================================================== diff --git a/binaries/data/mods/official/scripts/entity_functions.js b/binaries/data/mods/official/scripts/entity_functions.js index 014959cbdb..ef609c53ac 100644 --- a/binaries/data/mods/official/scripts/entity_functions.js +++ b/binaries/data/mods/official/scripts/entity_functions.js @@ -352,18 +352,35 @@ function entityInitQuasi() id.civ_code = civ_code; } + /* + // Original unoptimized version of the above code (for reference) + if( this.traits.id && this.traits.id.civ ) + { + var id = this.traits.id; + id.civ_code = id.civ.toString().substring (0, 4); + id.civ_code = id.civ_code.toString().toLowerCase(); + + // Exception to make the Romans into rome. + if (id.civ_code == "roma") id.civ_code = "rome"; + // Exception to make the Hellenes into hele. + if (id.civ_code == "hell") id.civ_code = "hele"; + } + */ + stopXTimer(7); + /* + // Profiling code for comparing performance of pure JavaScript objects vs. CJSComplex. // This should be removed when we're done optimizing entity init. var ob = new Object(); ob.traits = new Object(); - for(var i=0; i<10; i++) { + for(var i=0; i<50; i++) { ob["temp"+i] = "blah"; } - for(var i=0; i<10; i++) { + for(var i=0; i<50; i++) { ob.traits["temp"+i] = "blah"; } @@ -386,6 +403,8 @@ function entityInitQuasi() } stopXTimer(9); + + */ } // ====================================================================