I got new courage and I spend yesterday and today some time to find one of the causes that resets the random seed for descriptions. e.g. the following code resets the seed.
Code: Select all
log(System.systemNameForID(Math.floor(Math.random()*256)) + ": "+expandDescription("%R"))
Strange enough did
Code: Select all
log(System.systemNameForID(Math.floor(Math.random()*256)) + ": "+expandDescription("[nom1]"))
Diving more deep into the code, I see that anything with "%" in the description makes that the systemdata for the current system is generated. Normally it is cached, but when first accessing a different system, the cache has to be updated with the local system and here the seeds needs to be reset. (Resetting happens in 'DescriptionForSystem()')
I tested following fix:
Code: Select all
Index: /Users/ericwalch/Oolite/trunk/src/Core/Universe.m
===================================================================
--- /Users/ericwalch/Oolite/trunk/src/Core/Universe.m (revision 4642)
+++ /Users/ericwalch/Oolite/trunk/src/Core/Universe.m (working copy)
@@ -5867,6 +5867,7 @@
sCachedSystemData = nil;
cachedSeed = s_seed;
+ RNG_Seed saved_seed = currentRandomSeed();
NSMutableDictionary* systemdata = [[NSMutableDictionary alloc] init];
OOGovernmentID government = (s_seed.c / 8) & 7;
@@ -5917,7 +5918,7 @@
{
[systemdata setObject:DescriptionForSystem(s_seed,[systemdata oo_stringForKey:KEY_NAME]) forKey:KEY_DESCRIPTION];
}
-
+ if (useCache) setRandomSeed(saved_seed);
sCachedSystemData = [systemdata copy];
[systemdata release];
I try it a few days on my system and than do a commit. Unless anybody now already sees were this code could lead to a bug.
At a first test I see no wrong planet positions or different colors for planets.