Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernization #65

Open
wants to merge 1 commit into
base: Omega
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions src/StarField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,7 @@ int CStarField::Create(int iWidth, int iHeight)
m_Field.fMaxZ = 640.f;
m_Field.fLength = m_Field.fMaxZ - m_Field.fMinZ;

if (m_pStars)
{
delete[] m_pStars;
}

m_pStars = new ST_STAR[m_nStarCnt];

if (m_pStars == nullptr)
{
return -1;
}
m_pStars.resize(m_nStarCnt);

unsigned int n;

Expand All @@ -201,10 +191,10 @@ int CStarField::Create(int iWidth, int iHeight)
m_fBrightTable[n] = (float)(br * 255);
}

for (n = 0; n < m_nStarCnt; n++)
for (auto& star : m_pStars)
{
ResetStar(&m_pStars[n]);
m_pStars[n].z = RangeRand(m_Field.fMinZ, m_Field.fLength);
ResetStar(&star);
star.z = RangeRand(m_Field.fMinZ, m_Field.fLength);
}

for (n = 1; n < 256; n++)
Expand Down Expand Up @@ -249,9 +239,6 @@ char CStarField::GammaCorrect(unsigned char c, float g)

void CStarField::Destroy(void)
{
delete[] m_pStars;
m_pStars = nullptr;

m_pCurVertice = nullptr;
#ifndef WIN32
delete[] m_pVertices;
Expand All @@ -268,11 +255,6 @@ void CStarField::Destroy(void)

int CStarField::RenderFrame(void)
{
if (m_pStars == nullptr)
{
return -1;
}

m_Screen.fZoom = (float)m_Screen.iMidX * m_fZoom;
m_fVelocity += (m_fMaxVelocity - m_fVelocity) * .01f;

Expand Down
2 changes: 1 addition & 1 deletion src/StarField.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ATTR_DLL_LOCAL CStarField
ST_SCREEN m_Screen;
ST_FIELD m_Field;
ST_ROTATION m_Cam;
ST_STAR* m_pStars = nullptr;
std::vector<ST_STAR> m_pStars;
unsigned int m_nStarCnt;
unsigned int m_nDrawnStars;

Expand Down