[Change] A few more system gen float => int stuff. I didn't take into
account that different platforms will likely handle them differently, resulting in diferent starsystems being generated between platforms.
This commit is contained in:
parent
0017ed0bd3
commit
3a2fa73f2d
@ -20,19 +20,19 @@ Sector::Sector(int x, int y) {
|
|||||||
s.p.z = rng.Double(2*SIZE)-SIZE;
|
s.p.z = rng.Double(2*SIZE)-SIZE;
|
||||||
s.name = GenName(rng);
|
s.name = GenName(rng);
|
||||||
|
|
||||||
float spec = rng.Double(1.0);
|
float spec = rng.Int32(1000000);
|
||||||
/* Frequences are from our friends over at wikipedia. ^.^ */
|
/* Frequences are from our friends over at wikipedia. ^.^ */
|
||||||
if(spec < 0.0000003) {
|
if(spec < 1) {
|
||||||
s.primaryStarClass = StarSystem::TYPE_STAR_O;
|
s.primaryStarClass = StarSystem::TYPE_STAR_O;
|
||||||
} else if(spec < 0.0013) {
|
} else if(spec < 1300) {
|
||||||
s.primaryStarClass = StarSystem::TYPE_STAR_B;
|
s.primaryStarClass = StarSystem::TYPE_STAR_B;
|
||||||
} else if(spec < 0.0073) {
|
} else if(spec < 7300) {
|
||||||
s.primaryStarClass = StarSystem::TYPE_STAR_A;
|
s.primaryStarClass = StarSystem::TYPE_STAR_A;
|
||||||
} else if(spec < 0.0373) {
|
} else if(spec < 37300) {
|
||||||
s.primaryStarClass = StarSystem::TYPE_STAR_F;
|
s.primaryStarClass = StarSystem::TYPE_STAR_F;
|
||||||
} else if(spec < 0.1133) {
|
} else if(spec < 113300) {
|
||||||
s.primaryStarClass = StarSystem::TYPE_STAR_G;
|
s.primaryStarClass = StarSystem::TYPE_STAR_G;
|
||||||
} else if(spec < 0.2343) {
|
} else if(spec < 234300) {
|
||||||
s.primaryStarClass = StarSystem::TYPE_STAR_K;
|
s.primaryStarClass = StarSystem::TYPE_STAR_K;
|
||||||
} else {
|
} else {
|
||||||
s.primaryStarClass = StarSystem::TYPE_STAR_M;
|
s.primaryStarClass = StarSystem::TYPE_STAR_M;
|
||||||
|
@ -239,6 +239,11 @@ void StarSystem::SBody::EliminateBadChildren(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Choices that depend on floating point values will result in
|
||||||
|
* different universes on different platforms it seems.
|
||||||
|
* As a result we should avoid floating point values in these places.
|
||||||
|
*/
|
||||||
StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
||||||
unsigned long _init[3] = { system_idx, sector_x, sector_y };
|
unsigned long _init[3] = { system_idx, sector_x, sector_y };
|
||||||
loc.secX = sector_x;
|
loc.secX = sector_x;
|
||||||
@ -262,6 +267,7 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
|||||||
(int)bodyTypeInfo[type].tempMax);
|
(int)bodyTypeInfo[type].tempMax);
|
||||||
rootBody = primary;
|
rootBody = primary;
|
||||||
|
|
||||||
|
/* FIXME: Not good if the enum is tampered with... */
|
||||||
int disc_size = rand.Int32(6, 100) + rand.Int32(60,140)*primary->type*primary->type;
|
int disc_size = rand.Int32(6, 100) + rand.Int32(60,140)*primary->type*primary->type;
|
||||||
//printf("disc_size %.1fAU\n", disc_size/10.0);
|
//printf("disc_size %.1fAU\n", disc_size/10.0);
|
||||||
|
|
||||||
@ -285,11 +291,9 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
|||||||
matrix4x4d::RotateZMatrix(rand.Double(M_PI));
|
matrix4x4d::RotateZMatrix(rand.Double(M_PI));
|
||||||
primary->children.push_back(planet);
|
primary->children.push_back(planet);
|
||||||
|
|
||||||
double ang;
|
/* Perihelion and Aphelion. */
|
||||||
planet->orbit.KeplerPosAtTime(0, &planet->radMin, &ang);
|
planet->radMin = planet->orbit.semiMajorAxis - planet->orbit.eccentricity*planet->orbit.semiMajorAxis;
|
||||||
planet->orbit.KeplerPosAtTime(planet->orbit.period*0.5, &planet->radMax, &ang);
|
planet->radMax = 2*planet->orbit.semiMajorAxis - planet->radMin;
|
||||||
//printf(%f,%f\n", min/AU, max/AU);
|
|
||||||
//printf(%f year orbital period\n", planet->orbit.period / (60*60*24*365));
|
|
||||||
}
|
}
|
||||||
delete disc;
|
delete disc;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user