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.
This commit is contained in:
Matei
2006-07-17 02:38:43 +00:00
parent 9b98a19506
commit dd895c95e3
2 changed files with 27 additions and 2 deletions
@@ -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);
}
// ====================================================================
@@ -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);
*/
}
// ====================================================================