[Change] Some more renaming.

This commit is contained in:
Allanis 2018-01-14 14:32:13 +00:00
parent 887f330a36
commit ad8981690b
8 changed files with 45 additions and 43 deletions

View File

@ -63,13 +63,13 @@ const CustomSBody sol_system[] = {
{ {
"Io", StarSystem::TYPE_PLANET_HIGHLY_VOLCANIC, "Io", StarSystem::TYPE_PLANET_HIGHLY_VOLCANIC,
6, fixed(286,1000), fixed(15,1000), 130, 6, fixed(286,1000), fixed(15,1000), 130,
fixed(282,100000), fixed(41,10000), DEG2RAD(2.21), fixed(177, 10) fixed(282,100000), fixed(41,10000), DEG2RAD(2.21), fixed(177, 100)
}, },
{ {
"Europa", StarSystem::TYPE_PLANET_WATER, "Europa", StarSystem::TYPE_PLANET_WATER,
6, fixed(245,1000), fixed(8,1000), 102, 6, fixed(245,1000), fixed(8,1000), 102,
fixed(441,100000), fixed(9,1000), 0.0, fixed(355, 10) fixed(441,100000), fixed(9,1000), 0.0, fixed(355, 100)
}, },
{ 0 } { 0 }
}; };

View File

@ -32,8 +32,8 @@ void GenericSystemView::Draw3D(void) {
if(s && !s->IsSystem(px, py, pidx)) { if(s && !s->IsSystem(px, py, pidx)) {
s->GetPos(&px, &py, &pidx); s->GetPos(&px, &py, &pidx);
Sector sec(px, py); Sector sec(px, py);
Sector psec(L3D::playerLoc.secX, L3D::playerLoc.secY); Sector psec(L3D::playerLocSecX, L3D::playerLocSecY);
const float dist = Sector::DistanceBetween(&sec, pidx, &psec, L3D::playerLoc.sysIdx); const float dist = Sector::DistanceBetween(&sec,pidx, &psec, L3D::playerLocSysIdx);
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), "Dist. %.2f light years.", dist); snprintf(buf, sizeof(buf), "Dist. %.2f light years.", dist);

View File

@ -5,7 +5,6 @@
#include "gui.h" #include "gui.h"
#include "view.h" #include "view.h"
#include "mtrand.h" #include "mtrand.h"
#include "star_system.h"
class Player; class Player;
class SectorView; class SectorView;
@ -74,7 +73,9 @@ public:
static View* GetView(void) { return currentView; } static View* GetView(void) { return currentView; }
static StarSystem* GetSelectedSystem(void); static StarSystem* GetSelectedSystem(void);
static systemloc_t playerLoc; static int playerLocSecX;
static int playerLocSecY;
static int playerLocSysIdx;
static Player* player; static Player* player;
static SectorView* sectorView; static SectorView* sectorView;
static SystemInfoView* systemInfoView; static SystemInfoView* systemInfoView;

View File

@ -48,7 +48,9 @@ MTRand L3D::rng;
double L3D::gameTime; double L3D::gameTime;
float L3D::frameTime; float L3D::frameTime;
GLUquadric* L3D::gluQuadric; GLUquadric* L3D::gluQuadric;
systemloc_t L3D::playerLoc; int L3D::playerLocSecX;
int L3D::playerLocSecY;
int L3D::playerLocSysIdx;
void L3D::Init(IniConfig& config) { void L3D::Init(IniConfig& config) {
int width = config.Int("ScrWidth"); int width = config.Int("ScrWidth");
@ -337,7 +339,7 @@ void L3D::HyperspaceTo(StarSystem* dest) {
float ang = rng.Double(M_PI); float ang = rng.Double(M_PI);
L3D::player->SetPosition(vector3d(sin(ang)*AU, cos(ang)*AU,0)); L3D::player->SetPosition(vector3d(sin(ang)*AU, cos(ang)*AU,0));
L3D::player->SetVelocity(vector3d(0.0)); L3D::player->SetVelocity(vector3d(0.0));
dest->GetPos(&L3D::playerLoc); dest->GetPos(&L3D::playerLocSecX, &L3D::playerLocSecY, &L3D::playerLocSysIdx);
} }
IniConfig::IniConfig(const char* filename) { IniConfig::IniConfig(const char* filename) {

View File

@ -135,7 +135,7 @@ void SectorView::DrawSector(int sx, int sy) {
glRotatef(-m_rot_x, 1, 0, 0); glRotatef(-m_rot_x, 1, 0, 0);
glCallList(m_gluDiskDlist); glCallList(m_gluDiskDlist);
/* Player location indicator. */ /* Player location indicator. */
if((sx == L3D::playerLoc.secX) && (sy == L3D::playerLoc.secY) && (num == L3D::playerLoc.sysIdx)) { if((sx == L3D::playerLocSecX) && (sy == L3D::playerLocSecY) && (num == L3D::playerLocSysIdx)) {
shipstats_t stats; shipstats_t stats;
L3D::player->CalcStats(&stats); L3D::player->CalcStats(&stats);
glColor3f(0, 0, 1); glColor3f(0, 0, 1);

View File

@ -278,10 +278,10 @@ void StarSystem::SBody::EliminateBadChildren(void) {
if((*j) == (*i)) continue; if((*j) == (*i)) continue;
/* Don't eat anything bigger than self. */ /* Don't eat anything bigger than self. */
if((*j)->mass > (*i)->mass) continue; if((*j)->mass > (*i)->mass) continue;
fixed i_min = (*i)->radMin; fixed i_min = (*i)->orbMin;
fixed i_max = (*i)->radMax; fixed i_max = (*i)->orbMax;
fixed j_min = (*j)->radMin; fixed j_min = (*j)->orbMin;
fixed j_max = (*j)->radMax; fixed j_max = (*j)->orbMax;
fixed i_avg = (i_min+i_max)>>1; fixed i_avg = (i_min+i_max)>>1;
fixed j_avg = (j_min+j_max)>>1; fixed j_avg = (j_min+j_max)>>1;
bool eat = false; bool eat = false;
@ -341,8 +341,8 @@ void StarSystem::CustomGetChildOf(SBody* parent, const CustomSBody* customDef, c
parent->children.push_back(child); parent->children.push_back(child);
/* Perihelion and Aphelion (in AUS). */ /* Perihelion and Aphelion (in AUS). */
child->radMin = c->semiMajorAxis - c->eccentricity*c->semiMajorAxis; child->orbMin = c->semiMajorAxis - c->eccentricity*c->semiMajorAxis;
child->radMax = 2*c->semiMajorAxis - child->radMin; child->orbMax = 2*c->semiMajorAxis - child->orbMin;
CustomGetChildOf(child, customDef, i); CustomGetChildOf(child, customDef, i);
} }
@ -375,9 +375,9 @@ void StarSystem::GenerateFromCustom(const CustomSBody* customDef) {
*/ */
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[4] = { system_idx, sector_x, sector_y, UNIVERSE_SEED }; unsigned long _init[4] = { system_idx, sector_x, sector_y, UNIVERSE_SEED };
loc.secX = sector_x; m_secx = sector_x;
loc.secY = sector_y; m_secy = sector_y;
loc.sysIdx = system_idx; m_sysIdx = system_idx;
rootBody = 0; rootBody = 0;
if(system_idx == -1) return; if(system_idx == -1) return;
rand.seed(_init, 4); rand.seed(_init, 4);
@ -459,12 +459,12 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
star[1]->orbit.period = star[0]->orbit.period; star[1]->orbit.period = star[0]->orbit.period;
star[1]->orbit.rotMatrix = matrix4x4d::Identity(); star[1]->orbit.rotMatrix = matrix4x4d::Identity();
fixed radMin = semiMajorAxis - ecc*semiMajorAxis; fixed orbMin = semiMajorAxis - ecc*semiMajorAxis;
fixed radMax = 2*semiMajorAxis - radMin; fixed orbMax = 2*semiMajorAxis - orbMin;
star[0]->radMin = radMin; star[0]->orbMin = orbMin;
star[1]->radMin = radMin; star[1]->orbMin = orbMin;
star[0]->radMax = radMax; star[0]->orbMax = orbMax;
star[1]->radMax = radMax; star[1]->orbMax = orbMax;
centGrav->children.push_back(star[0]); centGrav->children.push_back(star[0]);
centGrav->children.push_back(star[1]); centGrav->children.push_back(star[1]);
@ -499,8 +499,8 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
primary->children.push_back(planet); primary->children.push_back(planet);
/* Perihelion and Aphelion. ( In AUs ) */ /* Perihelion and Aphelion. ( In AUs ) */
planet->radMin = semiMajorAxis - ecc*semiMajorAxis; planet->orbMin = semiMajorAxis - ecc*semiMajorAxis;
planet->radMax = 2*semiMajorAxis - planet->radMin; planet->orbMax = 2*semiMajorAxis - planet->orbMin;
} }
delete disc; delete disc;
@ -516,7 +516,7 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
buf[1] = 'b'+(idx++); buf[1] = 'b'+(idx++);
buf[2] = 0; buf[2] = 0;
(*i)->name = primary->name+buf; (*i)->name = primary->name+buf;
fixed d = ((*i)->radMin + (*i)->radMax) >> 1; fixed d = ((*i)->orbMin + (*i)->orbMax) >> 1;
(*i)->PickPlanetType(primary, d, rand, true); (*i)->PickPlanetType(primary, d, rand, true);
#ifdef DEBUG_DUMP #ifdef DEBUG_DUMP
@ -588,8 +588,8 @@ void StarSystem::SBody::PickPlanetType(SBody* star, const fixed distToPrimary, M
} else if(mass < 3) { } else if(mass < 3) {
if((averageTemp > CELSIUS-10) && (averageTemp < CELSIUS+70)) { if((averageTemp > CELSIUS-10) && (averageTemp < CELSIUS+70)) {
/* Try for life.. */ /* Try for life.. */
int minTemp = calcSurfaceTemp(star->radius, star->averageTemp, radMax, albedo, globalwarming); int minTemp = calcSurfaceTemp(star->radius, star->averageTemp, orbMax, albedo, globalwarming);
int maxTemp = calcSurfaceTemp(star->radius, star->averageTemp, radMin, albedo, globalwarming); int maxTemp = calcSurfaceTemp(star->radius, star->averageTemp, orbMin, albedo, globalwarming);
if((minTemp > CELSIUS-10) && (minTemp < CELSIUS+70) && if((minTemp > CELSIUS-10) && (minTemp < CELSIUS+70) &&
(maxTemp > CELSIUS-10) && (maxTemp < CELSIUS+70)) { (maxTemp > CELSIUS-10) && (maxTemp < CELSIUS+70)) {
type = TYPE_PLANET_INDIGENOUS_LIFE; type = TYPE_PLANET_INDIGENOUS_LIFE;
@ -637,8 +637,8 @@ void StarSystem::SBody::PickPlanetType(SBody* star, const fixed distToPrimary, M
matrix4x4d::RotateZMatrix(rand.NDouble(M_PI)); matrix4x4d::RotateZMatrix(rand.NDouble(M_PI));
this->children.push_back(moon); this->children.push_back(moon);
moon->radMin = semiMajorAxis - ecc*semiMajorAxis; moon->orbMin = semiMajorAxis - ecc*semiMajorAxis;
moon->radMax = 2*semiMajorAxis - moon->radMin; moon->orbMax = 2*semiMajorAxis - moon->orbMin;
} }
delete disc; delete disc;
@ -662,7 +662,7 @@ StarSystem::~StarSystem(void) {
} }
bool StarSystem::IsSystem(int sector_x, int sector_y, int system_idx) { bool StarSystem::IsSystem(int sector_x, int sector_y, int system_idx) {
return(sector_x == loc.secX) && (sector_y == loc.secY) && (system_idx == loc.sysIdx); return(sector_x == m_secx) && (sector_y == m_secy) && (system_idx == m_sysIdx);
} }
StarSystem::SBody::~SBody(void) { StarSystem::SBody::~SBody(void) {

View File

@ -13,10 +13,6 @@
#define AU 149598000000.0 #define AU 149598000000.0
#define G 6.67428e-11 #define G 6.67428e-11
struct systemloc_t {
int secX, secY, sysIdx;
};
struct CustomSBody; struct CustomSBody;
/* Doubles: All masses are in Kg, all lengths in meters. */ /* Doubles: All masses are in Kg, all lengths in meters. */
@ -26,9 +22,8 @@ public:
StarSystem(int sector_x, int sector_y, int system_idx); StarSystem(int sector_x, int sector_y, int system_idx);
~StarSystem(void); ~StarSystem(void);
bool IsSystem(int sector_x, int sector_y, int system_idx); bool IsSystem(int sector_x, int sector_y, int system_idx);
void GetPos(systemloc_t* l) { *l = loc; };
void GetPos(int* sec_x, int* sec_y, int* sys_idx) { void GetPos(int* sec_x, int* sec_y, int* sys_idx) {
*sec_x = loc.secX; *sec_y = loc.secY, *sys_idx = loc.sysIdx; *sec_x = m_secx; *sec_y = m_secy, *sys_idx = m_sysIdx;
} }
static float starColors[][3]; static float starColors[][3];
@ -113,7 +108,7 @@ public:
std::string name; std::string name;
fixed radius; fixed radius;
fixed mass; /* Earth masses if planet, solar masses if star. */ fixed mass; /* Earth masses if planet, solar masses if star. */
fixed radMin, radMax; /* In AU's. */ fixed orbMin, orbMax; /* Periapsism, Apoapsis in AUs. */
fixed rotationPeriod; /* In days. */ fixed rotationPeriod; /* In days. */
int averageTemp; int averageTemp;
@ -129,7 +124,8 @@ public:
private: private:
void CustomGetChildOf(SBody* parent, const CustomSBody* customDef, const int parentIdx); void CustomGetChildOf(SBody* parent, const CustomSBody* customDef, const int parentIdx);
void GenerateFromCustom(const CustomSBody*); void GenerateFromCustom(const CustomSBody*);
systemloc_t loc;
int m_secx, m_secy, m_sysIdx;
MTRand rand; MTRand rand;
}; };

View File

@ -40,12 +40,15 @@ void SystemInfoView::OnBodySelected(StarSystem::SBody* b) {
snprintf(buf, sizeof(buf), "Orbital period %.1f days\n", b->orbit.period/(60*60*24)); snprintf(buf, sizeof(buf), "Orbital period %.1f days\n", b->orbit.period/(60*60*24));
} }
desc += buf; desc += buf;
snprintf(buf, sizeof(buf), "Perihelion distance %.2f AU\n", b->radMin.ToDouble()); snprintf(buf, sizeof(buf), "Perihelion distance %.2f AU\n", b->orbMin.ToDouble());
desc += buf; desc += buf;
snprintf(buf, sizeof(buf), "Aphelion distance %.2f AU\n", b->radMax.ToDouble()); snprintf(buf, sizeof(buf), "Aphelion distance %.2f AU\n", b->orbMax.ToDouble());
desc += buf; desc += buf;
snprintf(buf, sizeof(buf), "Eccentricity %.2f\n", b->orbit.eccentricity); snprintf(buf, sizeof(buf), "Eccentricity %.2f\n", b->orbit.eccentricity);
desc += buf; desc += buf;
const float dayLen = b->GetRotationPeriod();
if(dayLen) snprintf(buf, sizeof(buf), "Day length %.1f earth days\n", dayLen/(60*60*24));
desc += buf;
} }
m_infoText->SetText(desc); m_infoText->SetText(desc);
} }