[Change] Renaming a few stuff to comply with convention.

This commit is contained in:
Rtch90 2018-01-14 14:11:21 +00:00
parent e2fb5081a7
commit 9e40edb0cb
11 changed files with 77 additions and 72 deletions

View File

@ -18,7 +18,7 @@ void Frame::RemoveChild(Frame* f) {
} }
void Frame::Init(Frame* parent, const char* label, unsigned int flags) { void Frame::Init(Frame* parent, const char* label, unsigned int flags) {
sBody = 0; m_sBody = 0;
m_parent = parent; m_parent = parent;
m_flags = flags; m_flags = flags;
m_radius = 0; m_radius = 0;

View File

@ -42,7 +42,7 @@ public:
/* If parent is null then frame position is absolute. */ /* If parent is null then frame position is absolute. */
Frame* m_parent; Frame* m_parent;
std::list<Frame*> m_children; std::list<Frame*> m_children;
StarSystem::SBody* sBody; /* Points to SBodies in L3D::current_system. */ StarSystem::SBody* m_sBody; /* Points to SBodies in L3D::current_system. */
enum { TEMP_VIEWING=1 }; enum { TEMP_VIEWING=1 };

View File

@ -68,35 +68,35 @@ public:
enum MapView { MAP_NOMAP, MAP_SECTOR, MAP_SYSTEM }; enum MapView { MAP_NOMAP, MAP_SECTOR, MAP_SYSTEM };
static void SetCamType(enum CamType); static void SetCamType(enum CamType);
static void SetMapView(enum MapView); static void SetMapView(enum MapView);
static enum CamType GetCamType(void) { return cam_type; } static enum CamType GetCamType(void) { return camType; }
static enum MapView GetMapView(void) { return map_view; } static enum MapView GetMapView(void) { return mapView; }
static void SetView(View* v); static void SetView(View* v);
static View* GetView(void) { return current_view; } static View* GetView(void) { return currentView; }
static StarSystem* GetSelectedSystem(void); static StarSystem* GetSelectedSystem(void);
static systemloc_t playerLoc; static systemloc_t playerLoc;
static Player* player; static Player* player;
static SectorView* sector_view; static SectorView* sectorView;
static SystemInfoView* system_info_view; static SystemInfoView* systemInfoView;
static WorldView* world_view; static WorldView* worldView;
static ObjectViewerView* objectViewerView; static ObjectViewerView* objectViewerView;
static SpaceStationView* spaceStationView; static SpaceStationView* spaceStationView;
static InfoView* infoView; static InfoView* infoView;
static ShipCpanel* cpan; static ShipCpanel* cpan;
static GLUquadric* gluQuadric; static GLUquadric* gluQuadric;
static StarSystem* current_system; static StarSystem* currentSystem;
private: private:
static void InitOpenGL(void); static void InitOpenGL(void);
static void HandleEvents(void); static void HandleEvents(void);
static View* current_view; static View* currentView;
static SystemView* system_view; static SystemView* systemView;
static double gameTime; static double gameTime;
static StarSystem* selected_system; static StarSystem* selectedSystem;
static enum CamType cam_type; static enum CamType camType;
static enum MapView map_view; static enum MapView mapView;
static float timeAccel; static float timeAccel;
static float frameTime; static float frameTime;
static int scrWidth, scrHeight; static int scrWidth, scrHeight;

View File

@ -30,20 +30,20 @@ sigc::signal<void, int, int, int> L3D::onMouseButtonDown;
char L3D::keyState[SDLK_LAST]; char L3D::keyState[SDLK_LAST];
char L3D::mouseButton[5]; char L3D::mouseButton[5];
int L3D::mouseMotion[2]; int L3D::mouseMotion[2];
enum L3D::CamType L3D::cam_type; enum L3D::CamType L3D::camType;
enum L3D::MapView L3D::map_view; enum L3D::MapView L3D::mapView;
Player* L3D::player; Player* L3D::player;
View* L3D::current_view; View* L3D::currentView;
WorldView* L3D::world_view; WorldView* L3D::worldView;
ObjectViewerView* L3D::objectViewerView; ObjectViewerView* L3D::objectViewerView;
SpaceStationView* L3D::spaceStationView; SpaceStationView* L3D::spaceStationView;
InfoView* L3D::infoView; InfoView* L3D::infoView;
SectorView* L3D::sector_view; SectorView* L3D::sectorView;
SystemView* L3D::system_view; SystemView* L3D::systemView;
SystemInfoView* L3D::system_info_view; SystemInfoView* L3D::systemInfoView;
ShipCpanel* L3D::cpan; ShipCpanel* L3D::cpan;
StarSystem* L3D::selected_system; StarSystem* L3D::selectedSystem;
StarSystem* L3D::current_system; StarSystem* L3D::currentSystem;
MTRand L3D::rng; MTRand L3D::rng;
double L3D::gameTime; double L3D::gameTime;
float L3D::frameTime; float L3D::frameTime;
@ -125,23 +125,23 @@ void L3D::Quit(void) {
} }
void L3D::SetCamType(enum CamType c) { void L3D::SetCamType(enum CamType c) {
cam_type = c; camType = c;
map_view = MAP_NOMAP; mapView = MAP_NOMAP;
SetView(world_view); SetView(worldView);
} }
void L3D::SetMapView(enum MapView v) { void L3D::SetMapView(enum MapView v) {
map_view = v; mapView = v;
if(v == MAP_SECTOR) if(v == MAP_SECTOR)
SetView(sector_view); SetView(sectorView);
else else
SetView(system_view); SetView(systemView);
} }
void L3D::SetView(View* v) { void L3D::SetView(View* v) {
if(current_view) current_view->HideAll(); if(currentView) currentView->HideAll();
current_view = v; currentView = v;
current_view->ShowAll(); currentView->ShowAll();
} }
void L3D::HandleEvents(void) { void L3D::HandleEvents(void) {
@ -207,7 +207,7 @@ void L3D::MainLoop(void) {
Frame* stationFrame = new Frame(pframe, "Station frame.."); Frame* stationFrame = new Frame(pframe, "Station frame..");
stationFrame->SetRadius(5000); stationFrame->SetRadius(5000);
stationFrame->sBody = 0; stationFrame->m_sBody = 0;
stationFrame->SetPosition(vector3d(0, 0, zpos)); stationFrame->SetPosition(vector3d(0, 0, zpos));
stationFrame->SetAngVelocity(vector3d(0,0,0.5)); stationFrame->SetAngVelocity(vector3d(0,0,0.5));
@ -235,15 +235,15 @@ void L3D::MainLoop(void) {
cpan = new ShipCpanel(); cpan = new ShipCpanel();
cpan->ShowAll(); cpan->ShowAll();
sector_view = new SectorView(); sectorView = new SectorView();
system_view = new SystemView(); systemView = new SystemView();
system_info_view = new SystemInfoView(); systemInfoView = new SystemInfoView();
world_view = new WorldView(); worldView = new WorldView();
objectViewerView = new ObjectViewerView(); objectViewerView = new ObjectViewerView();
spaceStationView = new SpaceStationView(); spaceStationView = new SpaceStationView();
infoView = new InfoView(); infoView = new InfoView();
SetView(world_view); SetView(worldView);
player->SetDockedWith(station); player->SetDockedWith(station);
Uint32 last_stats = SDL_GetTicks(); Uint32 last_stats = SDL_GetTicks();
@ -256,7 +256,7 @@ void L3D::MainLoop(void) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
current_view->Draw3D(); currentView->Draw3D();
/* /*
* TODO: HandleEvents at the moment must be after view->Draw3D and before * TODO: HandleEvents at the moment must be after view->Draw3D and before
* Gui::Draw so that labels drawn to screen can have mouse events correctly * Gui::Draw so that labels drawn to screen can have mouse events correctly
@ -296,7 +296,7 @@ void L3D::MainLoop(void) {
Space::TimeStep(step); Space::TimeStep(step);
gameTime += step; gameTime += step;
} }
current_view->Update(); currentView->Update();
if(SDL_GetTicks() - last_stats > 1000) { if(SDL_GetTicks() - last_stats > 1000) {
snprintf(fps_readout, sizeof(fps_readout), "%d fps", frame_stat); snprintf(fps_readout, sizeof(fps_readout), "%d fps", frame_stat);
@ -308,29 +308,29 @@ void L3D::MainLoop(void) {
StarSystem* L3D::GetSelectedSystem(void) { StarSystem* L3D::GetSelectedSystem(void) {
int sector_x, sector_y, system_idx; int sector_x, sector_y, system_idx;
L3D::sector_view->GetSelectedSystem(&sector_x, &sector_y, &system_idx); L3D::sectorView->GetSelectedSystem(&sector_x, &sector_y, &system_idx);
if(system_idx == -1) { if(system_idx == -1) {
selected_system = 0; selectedSystem = 0;
return NULL; return NULL;
} }
if(selected_system) { if(selectedSystem) {
if(!selected_system->IsSystem(sector_x, sector_y, system_idx)) { if(!selectedSystem->IsSystem(sector_x, sector_y, system_idx)) {
delete selected_system; delete selectedSystem;
selected_system = 0; selectedSystem = 0;
} }
} }
if(!selected_system) { if(!selectedSystem) {
selected_system = new StarSystem(sector_x, sector_y, system_idx); selectedSystem = new StarSystem(sector_x, sector_y, system_idx);
} }
return selected_system; return selectedSystem;
} }
void L3D::HyperspaceTo(StarSystem* dest) { void L3D::HyperspaceTo(StarSystem* dest) {
int sec_x, sec_y, sys_idx; int sec_x, sec_y, sys_idx;
dest->GetPos(&sec_x, &sec_y, &sys_idx); dest->GetPos(&sec_x, &sec_y, &sys_idx);
if(current_system) delete current_system; if(currentSystem) delete currentSystem;
current_system = new StarSystem(sec_x, sec_y, sys_idx); currentSystem = new StarSystem(sec_x, sec_y, sys_idx);
Space::Clear(); Space::Clear();
Space::BuildSystem(); Space::BuildSystem();

View File

@ -179,7 +179,7 @@ void Player::DrawHUD(const Frame* cam_frame) {
&_pos.x, &_pos.y, &_pos.z)) { &_pos.x, &_pos.y, &_pos.z)) {
b->SetProjectedPos(_pos); b->SetProjectedPos(_pos);
b->SetOnscreen(true); b->SetOnscreen(true);
if(L3D::world_view->GetShowLabels()) Gui::Screen::RenderLabel(b->GetLabel(), _pos.x, _pos.y); if(L3D::worldView->GetShowLabels()) Gui::Screen::RenderLabel(b->GetLabel(), _pos.x, _pos.y);
} else } else
b->SetOnscreen(false); b->SetOnscreen(false);
} }

View File

@ -41,7 +41,7 @@ SectorView::~SectorView(void) {
} }
void SectorView::OnClickSystemInfo(void) { void SectorView::OnClickSystemInfo(void) {
L3D::SetView(L3D::system_info_view); L3D::SetView(L3D::systemInfoView);
} }
bool SectorView::GetSelectedSystem(int* sector_x, int* sector_y, int* system_idx) { bool SectorView::GetSelectedSystem(int* sector_x, int* sector_y, int* system_idx) {

View File

@ -195,12 +195,12 @@ void Ship::SetWheelState(bool down) {
void Ship::SetNavTarget(Body* const target) { void Ship::SetNavTarget(Body* const target) {
m_navTarget = target; m_navTarget = target;
L3D::world_view->UpdateCommsOptions(); L3D::worldView->UpdateCommsOptions();
} }
void Ship::SetCombatTarget(Body* const target) { void Ship::SetCombatTarget(Body* const target) {
m_combatTarget = target; m_combatTarget = target;
L3D::world_view->UpdateCommsOptions(); L3D::worldView->UpdateCommsOptions();
} }
bool Ship::IsFiringLasers(void) { bool Ship::IsFiringLasers(void) {

View File

@ -42,10 +42,10 @@ void Space::Clear(void) {
} }
void Space::MoveOrbitingObjectFrames(Frame* f) { void Space::MoveOrbitingObjectFrames(Frame* f) {
if(f->sBody) { if(f->m_sBody) {
/* Not too efficient. */ /* Not too efficient. */
vector3d pos = f->sBody->orbit.CartesianPosAtTime(L3D::GetGameTime()); vector3d pos = f->m_sBody->orbit.CartesianPosAtTime(L3D::GetGameTime());
vector3d pos2 = f->sBody->orbit.CartesianPosAtTime(L3D::GetGameTime()+1.0); vector3d pos2 = f->m_sBody->orbit.CartesianPosAtTime(L3D::GetGameTime()+1.0);
vector3d vel = pos2 - pos; vector3d vel = pos2 - pos;
f->SetPosition(pos); f->SetPosition(pos);
f->SetVelocity(vel); f->SetVelocity(vel);
@ -74,7 +74,7 @@ static Frame* MakeFrameFor(StarSystem::SBody* sbody, Body* b, Frame* f) {
case StarSystem::SUPERTYPE_GAS_GIANT: case StarSystem::SUPERTYPE_GAS_GIANT:
case StarSystem::SUPERTYPE_ROCKY_PLANET: case StarSystem::SUPERTYPE_ROCKY_PLANET:
orbFrame = new Frame(f, sbody->name.c_str()); orbFrame = new Frame(f, sbody->name.c_str());
orbFrame->sBody = sbody; orbFrame->m_sBody = sbody;
orbFrame->SetRadius(10*sbody->GetRadius()); orbFrame->SetRadius(10*sbody->GetRadius());
assert(sbody->GetRotationPeriod() != 0); assert(sbody->GetRotationPeriod() != 0);
@ -87,7 +87,7 @@ static Frame* MakeFrameFor(StarSystem::SBody* sbody, Body* b, Frame* f) {
case StarSystem::SUPERTYPE_STAR: case StarSystem::SUPERTYPE_STAR:
default: default:
orbFrame = new Frame(f, sbody->name.c_str()); orbFrame = new Frame(f, sbody->name.c_str());
orbFrame->sBody = sbody; orbFrame->m_sBody = sbody;
orbFrame->SetRadius(1.2*sbody->GetRadius()); orbFrame->SetRadius(1.2*sbody->GetRadius());
b->SetFrame(orbFrame); b->SetFrame(orbFrame);
return orbFrame; return orbFrame;
@ -121,7 +121,7 @@ just_make_child:
} }
void Space::BuildSystem(void) { void Space::BuildSystem(void) {
GenBody(L3D::current_system->rootBody, rootFrame); GenBody(L3D::currentSystem->rootBody, rootFrame);
MoveOrbitingObjectFrames(rootFrame); MoveOrbitingObjectFrames(rootFrame);
} }

View File

@ -33,7 +33,7 @@ SpaceStationView::SpaceStationView(void) : View() {
void SpaceStationView::OnClickRequestLaunch(void) { void SpaceStationView::OnClickRequestLaunch(void) {
L3D::player->SetDockedWith(0); L3D::player->SetDockedWith(0);
L3D::SetView(L3D::world_view); L3D::SetView(L3D::worldView);
} }
void SpaceStationView::Draw3D(void) { void SpaceStationView::Draw3D(void) {

View File

@ -78,7 +78,9 @@ public:
}; };
struct SBody { class SBody {
public:
friend class StarSystem;
~SBody(void); ~SBody(void);
void EliminateBadChildren(void); /* :D */ void EliminateBadChildren(void); /* :D */
void PickPlanetType(SBody*, fixed distToPrimary, MTRand& drand, bool genMoons); void PickPlanetType(SBody*, fixed distToPrimary, MTRand& drand, bool genMoons);
@ -117,6 +119,9 @@ public:
BodySuperType supertype; BodySuperType supertype;
BodyType type; BodyType type;
private:
}; };
SBody* rootBody; SBody* rootBody;

View File

@ -166,7 +166,7 @@ void SystemView::Draw3D(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
int sector_x, sector_y, system_idx; int sector_x, sector_y, system_idx;
L3D::sector_view->GetSelectedSystem(&sector_x, &sector_y, &system_idx); L3D::sectorView->GetSelectedSystem(&sector_x, &sector_y, &system_idx);
if(m_system) { if(m_system) {
if(!m_system->IsSystem(sector_x, sector_y, system_idx)) { if(!m_system->IsSystem(sector_x, sector_y, system_idx)) {
delete m_system; delete m_system;