From ad8981690b419c27e07a2f485df02eb48281e222 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sun, 14 Jan 2018 14:32:13 +0000 Subject: [PATCH] [Change] Some more renaming. --- src/custom_starsystems.cpp | 4 ++-- src/generic_system_view.cpp | 4 ++-- src/l3d.h | 5 ++-- src/main.cpp | 6 +++-- src/sector_view.cpp | 2 +- src/star_system.cpp | 48 ++++++++++++++++++------------------- src/star_system.h | 12 ++++------ src/system_info_view.cpp | 7 ++++-- 8 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/custom_starsystems.cpp b/src/custom_starsystems.cpp index 3d0f75b..e0378be 100644 --- a/src/custom_starsystems.cpp +++ b/src/custom_starsystems.cpp @@ -63,13 +63,13 @@ const CustomSBody sol_system[] = { { "Io", StarSystem::TYPE_PLANET_HIGHLY_VOLCANIC, 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, 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 } }; diff --git a/src/generic_system_view.cpp b/src/generic_system_view.cpp index fad687f..5bd6fa9 100644 --- a/src/generic_system_view.cpp +++ b/src/generic_system_view.cpp @@ -32,8 +32,8 @@ void GenericSystemView::Draw3D(void) { if(s && !s->IsSystem(px, py, pidx)) { s->GetPos(&px, &py, &pidx); Sector sec(px, py); - Sector psec(L3D::playerLoc.secX, L3D::playerLoc.secY); - const float dist = Sector::DistanceBetween(&sec, pidx, &psec, L3D::playerLoc.sysIdx); + Sector psec(L3D::playerLocSecX, L3D::playerLocSecY); + const float dist = Sector::DistanceBetween(&sec,pidx, &psec, L3D::playerLocSysIdx); char buf[256]; snprintf(buf, sizeof(buf), "Dist. %.2f light years.", dist); diff --git a/src/l3d.h b/src/l3d.h index de4544f..742b91b 100644 --- a/src/l3d.h +++ b/src/l3d.h @@ -5,7 +5,6 @@ #include "gui.h" #include "view.h" #include "mtrand.h" -#include "star_system.h" class Player; class SectorView; @@ -74,7 +73,9 @@ public: static View* GetView(void) { return currentView; } static StarSystem* GetSelectedSystem(void); - static systemloc_t playerLoc; + static int playerLocSecX; + static int playerLocSecY; + static int playerLocSysIdx; static Player* player; static SectorView* sectorView; static SystemInfoView* systemInfoView; diff --git a/src/main.cpp b/src/main.cpp index 9d662d8..ed87888 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,7 +48,9 @@ MTRand L3D::rng; double L3D::gameTime; float L3D::frameTime; GLUquadric* L3D::gluQuadric; -systemloc_t L3D::playerLoc; +int L3D::playerLocSecX; +int L3D::playerLocSecY; +int L3D::playerLocSysIdx; void L3D::Init(IniConfig& config) { int width = config.Int("ScrWidth"); @@ -337,7 +339,7 @@ void L3D::HyperspaceTo(StarSystem* dest) { float ang = rng.Double(M_PI); L3D::player->SetPosition(vector3d(sin(ang)*AU, cos(ang)*AU,0)); L3D::player->SetVelocity(vector3d(0.0)); - dest->GetPos(&L3D::playerLoc); + dest->GetPos(&L3D::playerLocSecX, &L3D::playerLocSecY, &L3D::playerLocSysIdx); } IniConfig::IniConfig(const char* filename) { diff --git a/src/sector_view.cpp b/src/sector_view.cpp index 47c49ed..6ff5796 100644 --- a/src/sector_view.cpp +++ b/src/sector_view.cpp @@ -135,7 +135,7 @@ void SectorView::DrawSector(int sx, int sy) { glRotatef(-m_rot_x, 1, 0, 0); glCallList(m_gluDiskDlist); /* 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; L3D::player->CalcStats(&stats); glColor3f(0, 0, 1); diff --git a/src/star_system.cpp b/src/star_system.cpp index e7ad7cf..c2545f9 100644 --- a/src/star_system.cpp +++ b/src/star_system.cpp @@ -278,10 +278,10 @@ void StarSystem::SBody::EliminateBadChildren(void) { if((*j) == (*i)) continue; /* Don't eat anything bigger than self. */ if((*j)->mass > (*i)->mass) continue; - fixed i_min = (*i)->radMin; - fixed i_max = (*i)->radMax; - fixed j_min = (*j)->radMin; - fixed j_max = (*j)->radMax; + fixed i_min = (*i)->orbMin; + fixed i_max = (*i)->orbMax; + fixed j_min = (*j)->orbMin; + fixed j_max = (*j)->orbMax; fixed i_avg = (i_min+i_max)>>1; fixed j_avg = (j_min+j_max)>>1; bool eat = false; @@ -341,8 +341,8 @@ void StarSystem::CustomGetChildOf(SBody* parent, const CustomSBody* customDef, c parent->children.push_back(child); /* Perihelion and Aphelion (in AUS). */ - child->radMin = c->semiMajorAxis - c->eccentricity*c->semiMajorAxis; - child->radMax = 2*c->semiMajorAxis - child->radMin; + child->orbMin = c->semiMajorAxis - c->eccentricity*c->semiMajorAxis; + child->orbMax = 2*c->semiMajorAxis - child->orbMin; CustomGetChildOf(child, customDef, i); } @@ -375,10 +375,10 @@ void StarSystem::GenerateFromCustom(const CustomSBody* customDef) { */ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) { unsigned long _init[4] = { system_idx, sector_x, sector_y, UNIVERSE_SEED }; - loc.secX = sector_x; - loc.secY = sector_y; - loc.sysIdx = system_idx; - rootBody = 0; + m_secx = sector_x; + m_secy = sector_y; + m_sysIdx = system_idx; + rootBody = 0; if(system_idx == -1) return; 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.rotMatrix = matrix4x4d::Identity(); - fixed radMin = semiMajorAxis - ecc*semiMajorAxis; - fixed radMax = 2*semiMajorAxis - radMin; - star[0]->radMin = radMin; - star[1]->radMin = radMin; - star[0]->radMax = radMax; - star[1]->radMax = radMax; + fixed orbMin = semiMajorAxis - ecc*semiMajorAxis; + fixed orbMax = 2*semiMajorAxis - orbMin; + star[0]->orbMin = orbMin; + star[1]->orbMin = orbMin; + star[0]->orbMax = orbMax; + star[1]->orbMax = orbMax; centGrav->children.push_back(star[0]); 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); /* Perihelion and Aphelion. ( In AUs ) */ - planet->radMin = semiMajorAxis - ecc*semiMajorAxis; - planet->radMax = 2*semiMajorAxis - planet->radMin; + planet->orbMin = semiMajorAxis - ecc*semiMajorAxis; + planet->orbMax = 2*semiMajorAxis - planet->orbMin; } delete disc; @@ -516,7 +516,7 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) { buf[1] = 'b'+(idx++); buf[2] = 0; (*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); #ifdef DEBUG_DUMP @@ -588,8 +588,8 @@ void StarSystem::SBody::PickPlanetType(SBody* star, const fixed distToPrimary, M } else if(mass < 3) { if((averageTemp > CELSIUS-10) && (averageTemp < CELSIUS+70)) { /* Try for life.. */ - int minTemp = calcSurfaceTemp(star->radius, star->averageTemp, radMax, albedo, globalwarming); - int maxTemp = calcSurfaceTemp(star->radius, star->averageTemp, radMin, albedo, globalwarming); + int minTemp = calcSurfaceTemp(star->radius, star->averageTemp, orbMax, albedo, globalwarming); + int maxTemp = calcSurfaceTemp(star->radius, star->averageTemp, orbMin, albedo, globalwarming); if((minTemp > CELSIUS-10) && (minTemp < CELSIUS+70) && (maxTemp > CELSIUS-10) && (maxTemp < CELSIUS+70)) { 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)); this->children.push_back(moon); - moon->radMin = semiMajorAxis - ecc*semiMajorAxis; - moon->radMax = 2*semiMajorAxis - moon->radMin; + moon->orbMin = semiMajorAxis - ecc*semiMajorAxis; + moon->orbMax = 2*semiMajorAxis - moon->orbMin; } delete disc; @@ -662,7 +662,7 @@ StarSystem::~StarSystem(void) { } 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) { diff --git a/src/star_system.h b/src/star_system.h index 0a0e19f..aa40b27 100644 --- a/src/star_system.h +++ b/src/star_system.h @@ -13,10 +13,6 @@ #define AU 149598000000.0 #define G 6.67428e-11 -struct systemloc_t { - int secX, secY, sysIdx; -}; - struct CustomSBody; /* 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(void); 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) { - *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]; @@ -113,7 +108,7 @@ public: std::string name; fixed radius; 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. */ int averageTemp; @@ -129,7 +124,8 @@ public: private: void CustomGetChildOf(SBody* parent, const CustomSBody* customDef, const int parentIdx); void GenerateFromCustom(const CustomSBody*); - systemloc_t loc; + + int m_secx, m_secy, m_sysIdx; MTRand rand; }; diff --git a/src/system_info_view.cpp b/src/system_info_view.cpp index 5fd514a..d776478 100644 --- a/src/system_info_view.cpp +++ b/src/system_info_view.cpp @@ -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)); } 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; - 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; snprintf(buf, sizeof(buf), "Eccentricity %.2f\n", b->orbit.eccentricity); 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); }